Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private VideoPlayer1 As VideoPlayer
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("1")
NavControl.ShowPage(Page1)
VideoPlayer1.LoadVideoUrl("https://stream.radioparadise.com/aac-24")
Wait For VideoPlayer1_Ready (Success As Boolean)
If Success Then
Dim Player As NativeObject = VideoPlayer1.As(NativeObject).GetField("controller").GetField("player")
Dim PlayerItem As NativeObject = Player.GetField("currentItem")
Dim Metadata As NativeObject
Metadata = Metadata.Initialize("AVPlayerItemMetadataOutput").RunMethod("alloc", Null).RunMethod("initWithIdentifiers:", Array(Null))
Me.As(NativeObject).RunMethod("setDelegate::", Array(Metadata, VideoPlayer1))
PlayerItem.RunMethod("addOutput:", Array(Metadata))
VideoPlayer1.Play 'to start playing automatically
End If
End Sub
Private Sub VideoPlayer1_Metadata(Groups As Object)
For Each MetadataGroup As NativeObject In Groups.As(List)
For Each item As NativeObject In MetadataGroup.GetField("items").As(List)
Log("Key: " & item.GetField("key").AsString)
Log("Value: " & item.GetField("value").AsString)
Next
Next
End Sub
#if OBJC
- (void)setDelegate:(AVPlayerItemMetadataOutput*)meta :(B4IVideoPlayer*)player {
[meta setDelegate:player queue:dispatch_get_main_queue()];
}
@end
@interface B4IVideoPlayer (AVPlayerItemMetadataOutputPushDelegate) <AVPlayerItemMetadataOutputPushDelegate>
@end
@implementation B4IVideoPlayer (AVPlayerItemMetadataOutputPushDelegate)
- (void)metadataOutput:(AVPlayerItemMetadataOutput *)output
didOutputTimedMetadataGroups:(NSArray<AVTimedMetadataGroup *> *)groups
fromPlayerItemTrack:(AVPlayerItemTrack *)track {
NSLog(@"metadataOutput");
[B4IObjectWrapper raiseUIEvent:[self valueForKey:@"controller"] :@"_metadata:" :@[groups]];
}
#End If