mercredi 25 mars 2015

Play sound when iPhone sound switch is on silent mode in xamarin.iOS

I want to play video with full sound, even i have the sound switch(positioned above volume buttons) set to silent mode. What i did is working on iOS 7.x and 8.1.x but doesn't work on 8.2. It's quite weird, not really sure. How to go about it. Any sample code will be appreciated.


I don't want to change to AVPlayer,at this stage, as i am almost ready for release


Here's what i have already tried and works in 7.x and 8.1.x



//I declare a class level variable
MPMusicPlayerController VolumeRocker;

//initialize it
VolumeRocker = MPMusicPlayerController.ApplicationMusicPlayer;

//Use it. I set this inside the click even of button
//which i use to start playback of video

VolumeRocker.Volume = 1f;


Am i missing something ? This works in following scenarios in 7.x and 8.1.x,(but doesn't work on iOS 8.2, not sure abt 8.3)


1) I switch to silent mode and start playing the video. I get to see the volume popup and i can hear the sound


2) I set the volume to zero with sound switch set to ringer mode, i play the video , i get the volume popup. I can hear the sound, then i switch the sound mode to silent using the switch, i can still hear the sound. Even if i keep toggling the modes using the switch, it doesn't affect the volume of the video(which is what i need).




Aucun commentaire:

Enregistrer un commentaire