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.
Related
I have an app that records a video/audio like Instagram stories with avassetwriter and simultaneously plays an audio background music file with avaudioplayer. It both records and plays great.
The problem I am noticing though, is when I play back the recording, the background music is extremely loud, and I'm assuming it's because the mic and the bottom-of-the-phone default speaker, through which the audio background music is playing out of, are situated right next to each other - even though when I record it sounds like it's not that loud.
Is there any possible way or workaround that results in allowing the background music to play while recording but to not have it actually be recorded? I'm stumped on what my options are, and am desperately hoping to see if anyone else had any ideas/thoughts as I couldn't find any existing content addressing this issue.
I have to do a Video streaming app (using a remote url) in swift. But there is no any exact video format. Sometimes it can be m3u8 sometimes mp4 etc.. but my video player should support for what ever the format comes from the back end.
Also when the app is in background, the audio should play and when the app comes foreground video should play without any time delay between the vide and the audio.
I want to know whether is it possible to achieve my objectives using AVPlayerViewController or else what is the best player that I can use to achieve my targets. Please help me.
Thanks
AVPlayerViewController supports m3u8 and mp4 both format. For playing video's audio you need some extra configuration. You can check from here...
How do I get my AVPlayer to play while app is in background?
Is it possible to play video using Avplayer in Background?
So according to me AVPlayerViewController is best option for your requirement.
I have question. How play music from php/html and others without quicktime player. When i pushed to button in php with mp3 url my iPhone open automaticly quicktime player. But i need only play music from site without quicktimeplayer. How it's make saying please..
You could try using the <audio> tag. See here: http://www.codeproject.com/Tips/226992/Back-Ground-Music-in-Html5
If you don't want to play it immediately, leave off the autoplay attribute and call the .play() function at a later point. (See also: Playing audio with Javascript?)
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.
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.