Search code examples
xamarin.iosmpmovieplayeravaudiosession

Monotouch: Play movie without interrupting audio of other apps e.g. iPod


I have a silent movie (No sound at all in that clip) which acts as a background movie for my view.

When I play music with iPod and then open my app the iPod music stops.

I don´t want my movie to interrupt the iPod Audio. I´ve read that UseApplicationAudioSession is deprecated but how do I realize this now?

Thank you for your help!

EDIT: And because I add an image onto the MovieplayerViewController I can not use AVPlayer.

PS: Other threads I´ve found here do mention the deprecated UseApplicationAudioSession solution thats why I opened a new question.

Thanks :)


Solution

  • Here is my solution:

    AVAudioSession audioSession = AVAudioSession.SharedInstance();
    
                        NSError audioSessionError = new NSError();
    
                        audioSession.SetCategory(new NSString("AVAudioSessionCategoryAmbient"), out audioSessionError);