#Region Project Attributes
#ApplicationLabel: AudioTest
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: False
#MinVersion: 8
#PlistExtra: <key>UIBackgroundModes</key><array><string>audio</string></array>
#End Region
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private vp1 As VideoPlayer
Private Test1 As Button
Private Test2 As Button
Private NativeMe As NativeObject
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
NativeMe = Me
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
Page1.RootPanel.LoadLayout("layMain")
NavControl.ShowPage(Page1)
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
End Sub
Public Sub ControlEvent (Command As String)
Select Command
Case "play"
vp1.Play
Case "pause"
vp1.Pause
End Select
End Sub
Sub Test1_Click
NativeMe.RunMethod("setAudioSession", Null)
vp1.LoadVideoUrl("http://www.hosting-serv.com:9090/;")
vp1.Play
NativeMe.RunMethod("register", Null)
End Sub
Sub Test2_Click
NativeMe.RunMethod("setAudioSession", Null)
vp1.LoadVideoUrl("http://stream-dc1.radioparadise.com/mp3-32")
vp1.Play
NativeMe.RunMethod("register", Null)
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];
success = [audioSession setPreferredSampleRate:4096 error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}
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