iOS Question il_AudioPlayer - View

ilan

Expert
Licensed User
Longtime User
i was looking for a good audio player for b4i and found only the videoplayer view. but i had problems with it to show the player controls when the app is in background mode. it was shown on the first start but later they disappear. erels solution here: https://www.b4x.com/android/forum/threads/show-player-controllers-when-screen-is-off.118681/#content
using an AVQueuePlayer also did not fix the issue for me (running on iPhone 11 ios14 beta) so I create a custom view with some objective c codes and now everything works really fine. controls are always shown. I can control my music via headphones and there is also a nice UI.

what do you think?


if someone is interested in this view let me know. will post the lib soon (need some small modifications first)

this is how i create the player and add songs to it:

B4X:
Sub btn_Click
    Dim btn As Button = Sender
    Dim thememode As Int = btn.tag '0 = LightMode, 1 = DarkMode

    If audioplayer.IsInitialized = False Then
        audioplayer.Initialize(App,Me,Page1.RootPanel,"audioplayer",thememode,False,False)
        audioplayer.AP_SetLoopPlay(True)
        audioplayer.AP_SetRandomPlay(False)
        audioplayer.AP_Songlist.Clear
        audioplayer.AP_Songlist.Add(audioplayer.Ap_Createsong(0,File.DirAssets,"CRO - Traum (Official Version).mp3","CRO - Traum",False,Null,Null,""))
        audioplayer.AP_Songlist.Add(audioplayer.Ap_Createsong(1,File.DirAssets,"Mahmood - Soldimyfilesshare.mp3","Mahmood - Soldimyfilesshare",False,Null,Null,""))
        audioplayer.AP_Songlist.Add(audioplayer.Ap_Createsong(2,File.DirAssets,"rauf faik (official audio).mp3","rauf faik",False,Null,Null,""))
        audioplayer.Ap_SetSkipseconds(30)
        audioplayer.Ap_ShowSpecialButtons(True)
        audioplayer.AP_show
        audioplayer.AP_playTrack(0)
  
        '// change view color
        'Dim lbl As Label = audioplayer.returnTitleLabel
        'lbl.TextColor = Colors.Red

    Else
        audioplayer.AP_show
    End If
End Sub

i have implemented a lot of functions and full control of all views in it so it is very customizable.

Darkmode is also available (see attachment)

** EDIT: Lib is available here: https://www.b4x.com/android/forum/threads/il_audioplayer.120180/
 

Attachments

  • ilaudioplayerdarkmode.png
    ilaudioplayerdarkmode.png
    31.7 KB · Views: 276
Last edited:
Top