I can't for the life of me figure out how to determine when a video or audio file is done after clicking a link in a UIWebView..
For instance, a user clicks a link to a video in a UIWebView in my app. The default media player launches and loads up the video. The video plays and finishes (or the user hits the Done button) .. Where do I go from here? Seems like a pretty big oversight if there's absolutely no way of handling this user interaction.
In my personal example, I'd love to be able to stop refreshing an ad while a video or audio file is being played in a UIWebView from my app so that it doesn't keep refreshing in the background while no user will ever see the ads. I can stop the ads from refreshing by detecting the filetype when a link is clicked, but I have no method of restarting the timer.
I can't for the life of me figure out how to determine when a video or audio file is done after clicking a link in a UIWebView..
For instance, a user clicks a link to a video in a UIWebView in my app. The default media player launches and loads up the video. The video plays and finishes (or the user hits the Done button) .. Where do I go from here? Seems like a pretty big oversight if there's absolutely no way of handling this user interaction.
In my personal example, I'd love to be able to stop refreshing an ad while a video or audio file is being played in a UIWebView from my app so that it doesn't keep refreshing in the background while no user will ever see the ads. I can stop the ads from refreshing by detecting the filetype when a link is clicked, but I have no method of restarting the timer.
The closest I was able to find was error code 204. If you get that error, I've found that it's usually trying to open a video/audio file.. so I just set a variable in the webview:didFailLoadWithError method and then check for it in the webview:shouldStartLoadWithRequest method.. Kind of clunky and stupid, but that's the only way I've figured out so far.
I can't for the life of me figure out how to determine when a video or audio file is done after clicking a link in a UIWebView.
You can invoke the default MediaPlayer without opening a webview. In this case you know it's done by:
Code:
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
In situations where I do open media (e.g. mp3) in a webview, the Quicktime player appears for me automatically. When the file is finished playing, or when a user pushes the "Done" button that is shown by default, it just displays a screen with a play arrow on it for me. User can play the file again, or use the NavController to go back to the list.