Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
Dim no As NativeObject = Me
no.RunMethod("addListener", Null)
Volume_Changed
End Sub
#if OBJC
@import MediaPlayer;
@import AVFoundation;
- (void)addListener {
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:YES error:nil];
[audioSession addObserver:self
forKeyPath:@"outputVolume"
options:0
context:nil];
[[MPMusicPlayerController applicationMusicPlayer] volume];
}
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqual:@"outputVolume"]) {
[self.bi raiseEvent:nil event:@"volume_changed" params:nil];
}
}
#end if
Private Sub Volume_Changed
Dim no As NativeObject
Dim volume As Float = no.Initialize("MPMusicPlayerController").RunMethod("applicationMusicPlayer", Null).GetField("volume").AsNumber
Log(volume)
End Sub