Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
Dim xTitulo, xMsg As String
xTitulo = Message.Get("title")
xMsg = Message.Get("message")
Log($"Message arrived: ${Message}"$)
NativeMe.RunMethod("setAudioSession", Null)
MyPlayer1.Initialize(File.DirAssets, "manera.mp3","MyPlayEnd")
MyPlayer1.Looping=False
MyPlayer1.Play
' Msgbox(xMsg, xTitulo )
ch = CompletionHandler
' CompletionHandler.Complete
End Sub
#If OBJC
@import MediaPlayer;
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
- (void)setAudioSession {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&err];
if (success) {
success = [audioSession setActive:YES error:&err];
}
if (!success)
[NSException raise:@"" format:@"Error setting audio session: %@", err];
}
- (void)register {
MPRemoteCommandCenter* center = [MPRemoteCommandCenter sharedCommandCenter];
center.playCommand.enabled = true;
center.pauseCommand.enabled = true;
[center.playCommand addTarget:self action:@selector(play)];
[center.pauseCommand addTarget:self action:@selector(pause)];
}
- (void) play {
NSLog(@"test");
[self.bi raiseEvent:nil event:@"controlevent:" params:@[@"play"]];
}
- (void) pause {
[self.bi raiseEvent:nil event:@"controlevent:" params:@[@"pause"]];
}
#end if