Playing the multiple Audio files in different Views using single audio player instance in iphone, - iphone

I am new to audio playing, I am having one issue regarding Audio playing .The issue is Playing the multiple audio files , and controlling the current playing audio file from other Views.
My Requirement is. In my app i am having 4 audio files in different Views. Once the audio play button is clicked in some View, The audio playing has to be started and pause and stop and slider buttons has to be displayed , Even i navigated to the next view the audio has to be continued (I should be able to control the currently playing audio), If i pressed the navigated view's audio, The previous audio has to be stopped, Navigated page audio has to be played. After completion of Navigated page Audio, the resumed audio of Previous page has to be played.
As of my knowledge, I have take single audio instance in AppDelegate. I am referring that Audioplayer instance in all view's , Where ever i need. It is not working.(some times giving error , some times unable to stop the Previous Audio playing).
Thanks in advance.

if i am not wrong you have defined the audioplayer in appdelegate, right?
and which class are you using for this , avplayer , avaudioplayer or mpplayer ?
and by the way , if we come to answer of mine,
i have used avplayer and avaudioplayer for this kind of business and it worked without problem , have you checked that in everyview you initialize you appdelegate instance? if not please check this and
also in your plist file , you should state that app will play audio in background to get the support for that.
hope this answer will help! :)

Related

AirPlay flickering when switching between movies

I have an app that shows list of movies in a table view. When I play them one after another on device it works just great. But when I switch to Apple TV over AirPlay it doesn't work anymore. It play's the first video on ATV ok but after a switch to the next video the screen on ATV start blinking/flickering and after a few seconds it falls back playing on a device. I am using MPMoviePlayerController for playing stream videos.
I also found out that if previous video finished playing over AirPlay it tries to start the next one over AirPlay also. Is this intended behaviour?
Is this kind a related with property allowsAirPlay?
I think I've found a solution. Before you switch playing another video you should stop the previous one:
[self.moviePlayer stop];
This is not needed if you are not playing via AirPlay cos the next video will automatically stop previous one by nature - you can not play two videos at once.
But If you do play video over AirPlay you need to stop previous one first and than play the next one.
This solution works for me.

Continuous background audio with MPMoviePlayerController?

I am using MPMoviePlayerController to play streaming audio. I'm trying to get background audio working correctly. Right now, audio continues to play when you exit the app - the lock-screen and multi-tasking bar controls even work.
When a song finishes, the app is supposed to advance to the next track and play it. It works when the app is open but not when it is in the background (a song finishes but does not advance to the next track). If a song finishes and you re-open the app, however, the next song will start up immediately.
I am currently using NSNotificationCenter to keep track of when tracks end to advance to the next track (in my app delegate). Again, it works like a charm when the app is open. Is there a better way to do this to keep audio playing after a song is done?
I had this issue lately. Hope the answer helps other people.
If you have a playlist for example and want to play the next song while in background mode or lock mode add this line of code on your viewDidLoad:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
This makes the app supports remote control events.

Movie is played with some delay after calling play on MPMoviePlayerController

I am developing an iPhone application in which I play videos using MPMoviePlayerController.
Sometimes, some of the videos don't play immediately after I call play on MPMoviePlayerController.
I have called prepareToPlay and in the notified method of MPMediaPlaybackIsPreparedToPlayDidChangeNotification, I am calling play on MPMoviePlayerController.
Could someone help in identifying the problem here?
Thanks,
Laxmilal
From my answer in a similar thread (reducing-the-initial-delay-when-playing-remote-video-content) - Note this fragment of the solution is valid for both, remote and local video content.
Use theMPMoviePlayerController.movieSourceTypeproperty when initializing your
player to cut down the media
recognition delay.
From the MPMoviePlayerController Class Reference:
The default value of this property is
MPMovieSourceTypeUnknown. This
property provides a clue to the
playback system as to how it should
download and buffer the movie content.
If you know the source type of the
movie, setting the value of this
property before playback begins can
improve the load times for the movie
content. If you do not set the source
type explicitly before playback, the
movie player controller must gather
this information, which might delay
playback.

Combine two audio files together and play them in iPhone

I do not want any code but want to get a reference about my question mentioned below...
There is background music available and there is recording option in my app...
Once I start recording , application records my sound and when play button clicks , It will play the recording along with the background music...
I had use this Link but can not get as I want...
I think there is a mechanism like merging two audio files and make it one before playing....
How can I achieve this by coding... Is there any reference link or any sample code available?
Thnx in advance...
Most people mistake the one instance of AVAudioPlayer as the unit that plays the sound directly, but it doesnt. Mixing is done by the OS, not by the instance of AVAudioPlayer.
With other words:
No one says you can't have more then one AVAudioPlayer.
Create one for you background and let it play. Create another instance of AVAudioPlayer for you recorded sound and let it play. Voila

Play audio and video at a same time in iPhone application

Is it possible to play audio and video file at a same time? I want to play different audio file and video file at a same time and also want control for both, so is it possible?
Sorry, not that I know of. The movie view automatically stops all audio files and takes up the whole screen, so you are forced to listen to the audio for the video.
If the audio is part of the video file, yes.
If it's an MP3 file or some other external type how are you planning on playing it? The phone might allow this to happen depending on what you're up too.
You might be in luck soon though...
Another helpful link is here.