AVPlayer vs MPMoviePlayer - ipad

In my application I have to play videos of type .m3u8. These are not local video. I can do it either with MPMoviePlayerController or AVPlayer. I also have to ignore userinteraction when some advertisement is getting played. Also I have to give an option for Airplay.
Which player should I use?
Thanks.

AVPlayer has a subclass called AVQueuePlayer which allows you to play back several movies in a sequence. It would be helpful for you for your ads. AVplayer currently does not support Airplay.
From iOS 5 AVplayer has an option to start playing back automatically on Airplay by enabling usesAirPlayVideoWhileAirPlayScreenIsActive property (if allowsAirPlayVideo is also enabled)
As far as I know you cannot play on airplay automatically with MPMoviePlayer, user has to tap on the Airplay icon.

Related

Play Audio from URL ios

I am developing application like gaana.com
Which player can be used for play mp3 songs from server url ? I want
to implement Play, Pause, Next, Previous buttons And will also play
song list in background mode one by one.
I have already implemented AVPlayer but i getting issue in playing
next audio in background mode. And i had tried all answers regarding
this issue but none of all is working for me.
So i am finding alternative of AVPlayer.

iOS 6 AVAudioSession issue

In my application I have made [audioSession setCategory:AVAudioSessionCategoryPlayback] to play audio in back ground and also to mute other audio play backs while playing song in my application. I am playing the audio using AVPlayer and also I have UIWebView for playing video in same Application. The issue arises when I play both video in web view and audio using AVPlayer. The music mixes in this case. Prior to iOS 6 when I rech same situation one audio pauses automatically and the mixing up does not occur. So kindly suggest some solutions.
Try to set
Required background modes -> App plays audio
in Info.plist.

Airplay of audio using AVPlayer does not work in the background

I am doing audio playback using the AVPlayer class from a remote URL.
It plays fine if I just play to the headphones/built in speaker, but I am seeing some oddities with AirPlay.
When I change to use an AppleTV for AirPlay, it will stream the audio, but on my iphone the audio playback indicator (the small 'play' triangle in the top menu bar) disappears, and when I lock the phone instead of continuing in the background, it stops. (When playing normally, it plays in the background fine).
Why is the AVPlayer not working in the background for audio over AirPlay?
Is this what other see? Is there a way around it?
Ok - I dug through the apple dev forums and found a hint.
If you are using AVPlayer for audio only, and want it to work in the background while doing airplay, you need to disable the allowsAirPlayVideo setting.
Apparently AVPlayer on iOS 5+ assumes that it is playing back video via AirPlay, and so does not allow backgrounding, unless you explicitly disable video AirPlay.
Once you disable this (i.e. self.player.allowsAirPlayVideo = FALSE;) then your audio will still play via AirPlay, but now it will not be treated as video, only as audio, and so will allow the backgrounding to work.
Have you enable the 'Background Audio' mutlitasking setting in the app plist?

How to start playing a sound while iPod's screen is turned off?

I need to play a custom sound synthesized using AudioUnit on an iPod.
This sound shall be played after up to one hour of playing music from a playlist on the iPod (it is played using MPMusicPlayerController).
The issue is that everything works fine if the screen in on, however my custom sound doesn't play if the screen is off.
If the sound is already playing when the screen is turned off it keeps playing well. So I assume I am using the correct audio session category.
Could you give me any hint?
According to Apple's developer library:
AVAudioSessionCategoryPlayback or the equivalent
kAudioSessionCategory_MediaPlayback—Use this category for an
application whose audio playback is of primary importance. Your audio
plays even with the screen locked and with the Ring/Silent switch set
to silent.
(Also, check this table.)
It seems that setting the audio session category to AVAudioSessionCategoryPlayback or kAudioSessionCategory_MediaPlayback would automatically fix your problem.

avaudioplayer interferes with mpmovieplayer on ipad

my app plays video and audio. however, i have a problem where once i play an audio file using avaudioplayer, the video refuses to play. when i play the video first, everything is fine. but if the audio is played first, any time i try to play the video it simply pops up the video player but will not play the actual video (you can use the scroller to go to any point in the video, but no playback will happen). this issue does not come up on the iphone, nor on the ipad simulator. clearly there is some resource conflict here, probably related to the audio, and i'd welcome some input on how to address it.
issue solved: i had to call the 'stop' rather than 'pause' method on the avaudioplayer before video playback. this undoes the play preparation and releases the audio resource that had apparently prevented the video from being played.

Resources