I have an app that shows videos in a timeline. The videos autoplay and by default they should be silent. If the user is playing music in the background, music should not stop at this time. It is only when tapping the video that it should actually pause the background music and let the video play. And once the video is done playing, the user's previous audio should continue where it left off.
I've tried using
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
but this lets the music mix with the audio even if the video is in full screen mode. Of course, I could ensure that when the play button is tapped, the music pauses, but that might not be the cleanest solution.
Any better ideas?
Related
I have an app that at the beginning plays a video with AVPlayer. The video is muted. The problem is it stops the music that let say iPhone was playing on iTunes and after the video playback is finished the music does not come back automatically. Is there a way to play the video in my app, during the playback of the video the music on iTunes can be muted which is fine with me, but what I want to achieve is to get the iTunes music back playing when the video is finished without the user's interference.
I have an app that plays silent Movies using AVFoundation. Is there a way to allow the music to play and your iPod (if you're playing music) to continue playing? If I play the movie will my iPod is on, the iPod pauses so the movie can play, and vice versa - if I try to replay the music while the movie is playing, the movie pauses. Basically, I want them to play continue playing seamlessly....
Let me know if you need applicable code to answer.
In my experience, for standard AVAudioPlayer based sound in an app, managing the AVAudioSession is required to allow background music:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
But I can't tell you if that's the same as attempting to play encoded/compressed Video and encoded/compressed audio at the same time.
Im using AVPlayer to play song from URLs. I need to play songs continously when user play one song (all songs in the list one after the other) even when the screen doing to lock. But my problem is, when I play a song, after screen is lock current song is playing but the next song is not plays. This is my code.
Appdelegate.m
`
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);`
also set the info-plist Required background modes to App plays audio
If screen is not lock it plays allsongs one after the other. Only screen lock it plays the currently playing song only. How can I correct this issue.
Please help me,
Thanks
I have an app that plays several webvideos like Youtube and Vimeo in a UIWebView. When the video plays it is possible to send it to an Apple TV over AirPlay.
Currently, during playback over AirPlay the video stops when I pause the app and move it to the background.
My desired result is that the video will keep playing on the Apple TV.
After some research I found out that I have to set the Required background modes in the Info.plist to App plays audio. Unfortunately this did not work.
So what does need to be set to keep the video playing over AirPlay when the app is moved to the background.
i've tested this on iOS6 with UIWebView loading video webpage, and it does the job. the audio session needed to be set as AVAudioSessionCategoryPlayback in order to be played in background.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
I have a video with sounds, and I want to play other sounds on the background. So I want to stop the video music to keep playing just the other music. I have to code for all except to stop the music for the video. Is it possible to build?