AVPlayer restart sync issue - iphone

Hi all
Im working with AVPlayer app to run on an iPad and just getting my head around it. Currently stuck with an issue that i cant seem to get the avplayer to restart a currently playing file safely. The video doesnt need to be finished for a call for the command to restart is called.
[player[currentPage] seekToTime:startTime toleranceBefore:startTime toleranceAfter:startTime];
[player[currentPage] play];
is what im using at the moment and it works majority of the time but sometimes the video seems to go out of sync with the sound . that is to say the sound restarts fine but the video seems to be paused and doesnt restart until the sound catches back up with it.
Anyone have experience with this or can point me in the right direction to research it myself. I have gone through the avplayer class files on the apple dev site and have been unlucky with searching for similar problems.
Thanks for any help
G

Check out my answer for this question:
iOS Multiple AVPlayer objects results in loss of audio/video sync

Related

Starting audio in locked screen mode not working

I am working on a timer App with alerts. When the screen is locked I would like to have my alerts/Text To Speech keeping to work. It works for some time between 30 to 60 sec and then alerts stops working but the timer is continuing to work as when I unlock the phone the timer progressed and works. I went through many posts and I didn't find a solution. It looks like new audio cannot be fired in lock down mode (some posts said new audio sounds cannot be triggered in lock down but continuity of audio is working). I finally found this post -> AVFoundation playing audio in background/on lock screen in Swift
so I added following lines in my code:
// to authorize background music in parallel
try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.ambient)
try? AVAudioSession.sharedInstance().setActive(true)
// to play audio in background, lock screen mode
try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)
and in info.plist I have this entry:
The result is that short audio sounds are working (I trigger them every 30 sec) only if I lock the screen during an audio, if I do it between two sounds it stops. I spent many days on searching solutions but nothing works, can someone please help here?
Spending again some hours to search further on this topic and what I found: -> https://developer.apple.com/forums/thread/77937
seems really a problem for many people but I don't understand why we don't find any solution as I saw many apps with this feature working, if you see any good answer please tell me.
As no one had an answer I contacted Apple Developer Technical Support and the response was a bit surprising but there is no "clean way" to do it, here the answer I got:
"To continue playing audio from the background, continuously play audio in the background (mostly this will be silent, except for when you have a new “alert”)"
I tested it with a silent.wav file of 60 sec that I fire every 55 sec and it works!

VLCKit (iOS) mediaPlayer suddenly stops playing

I'm first-time user of MobileVLCKit-iOS (3.3.15) and have added VLCMediaPlayer() in a swift app to play audio urls. Randomly the mediaplayer receives a mediaPlayerStateChanged(.stopped) event, after buffering or immediately when executing play(). In other cases this audio url plays just fine.
What could be the reason for suddenly stopping? What can I do to solve this ? Unfortunately I receive no (error)info from the player...
Thanks for any advice
Frank
Seems to be no issue, probably has to do with the audio urls.

iPhone SDK - HTML Live Streaming for audio

I've been developing an iPhone application that streams audio using Matt Gallagher's audio streamer found here: GitHud: AudioStreamer
However, I'm having some problems when the iPhone loses internet connection because the stream cuts out and doesn't reconnect until the user actually presses the play button again. I've even tried using the reachability classes from Apple to try and automatically stop and reconnect the stream but this isn't working 100%.
I've been reading around on the internet and I've found something called HTTP Live Streaming that can supposedly be used to stream audio on the iPhone. However, I can't seem to find any examples of how to use this, therefore can anyone help me by given a brief description any any source that might help to get this working please?
Thanks in advance,
Luke
Not enough detail for me to answer this entirely, but I use a set of calls
to be notified of reachability changes.
When I get a failure, I change the play image to stop.
I then wait for a notification that the network is back
and then programmatically press play for the user.

AVAssetExportSession missing audio track when exporting on device

I run the export on the simulator and everything works great. I run it on the device and the video gets exported but there's no audio. This leads me to believe that I must be using an audio format that the device doesn't support but OS X does, as the simulator uses what OS X uses. I've tried m4a, aiff, and aifc and have had no luck! Any ideas??
I have a very similar problem. It does not seem to do with codecs, as I made a separate test case that runs fine with the same video. There’s a related question that says the problem might be in playing the same assets using MPMoviePlayerController. That got me on the right track (sort of).
In my case the trouble stem from using the assets in an AVPlayer during the export. I was not able to find the exact combination that causes the export to drop the audio track – in the separate test project the export runs fine even though the asset plays in AVPlayer at the same time. After several hours of trying to find the exact cause I gave up and simply popped the asset out of the player using replaceCurrentItemWithPlayerItem:nil during export. It’s a hack, but it works.
AVFoundation is a very powerful framework, but God I wish it wasn’t so finicky or at least logged more errors instead of silently producing garbage.

wav stopped working with AudioServices on my iPhone app?

I have a wav file that was working fine. It is played using the AudioServices methods. Suddenly it stopped working. The weird thing is if i change he wav file to a different one that works. Any idea what is going on? The non working sound is slightly longer (still <10seconds) but it was originally working so I just can't figure it out.
Any suggestions of what to try would be most appreciated. Thanks :-)
AudioServices won't play sounds longer than 5 seconds. Playing longer sounds will require using a different Audio approach.
Here's a decent example of playing sounds with another method:
http://iphoneincubator.com/blog/tutorial/how-to-play-audio-with-the-iphone-sdk