iOS Question [SOLVED] Media Player Framework

mdhugol

Member
Licensed User
Longtime User
Hi, hope someone in this forum can guide me, i know from other thread that i need to use (hidden) videoview to stream audio/video. But now i want to set Now Playing (MPNowPlayingInfoCenter from Media Player Framework) to set information about what is currently playing now in iOS device.

Anybody can help me how to achieve this in B4i (like code snippet, tutorial, etc) ?, or i have to create my own library for this ?

Thanks
 
Last edited:

JanPRO

Well-Known Member
Licensed User
Longtime User
B4X:
Sub SetNowPlayingInfo(Title As String, Artist As String, AlbumTitle As String)
    Dim Infos As Map
    Infos.Initialize

    Infos.Put("title",Title)
    Infos.Put("artist",Artist)
    Infos.Put("albumTitle",AlbumTitle)

    Dim NaObj As NativeObject = Me
    NaObj.RunMethod("SetInfos:",Array(Infos.ToDictionary))
End Sub

#if objc
@import MediaPlayer;

-(void)SetInfos:(NSMutableDictionary*)Dictionary{
    [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:Dictionary];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}
#end if

For other keys see https://developer.apple.com/library...rence/MPNowPlayingInfoCenter_Class/index.html

;)
 
Upvote 0

mdhugol

Member
Licensed User
Longtime User
Hi, thank you for your answer, i can compile the code successfully, but the information is not shown, any idea why.?
 
Upvote 0
Top