Movie Player in UIWebView - iphone

If I want to download an mp4 file, an iPhone movie player (MPMoviePlayerController) pops out and plays the video. My question is: can I get some kind of a message that it pops up or perhaps even prevent it from appearing?

One thing you could try is setting a delegate for your UIWebView and implementing -webView:shouldStartLoadWithRequest:navigationType:. Return NO if it's an mp4 (or mov) file.

Related

Using a webview to play an mp3- is it possible to keep it playing even when the screen is locked?

I have a portion of my app that simply launches a webview linked to an mp3 file- it opens the file and plays the audio. What I'd like to do is allow that audio to continue playing even if the user locks their iPhone. (As a side note, is there any way to replace the default Quicktime logo that appears in the player? Not that big a deal, just thought I'd ask =)
A third question- I also do the same thing (webview) with an .m3u linked file to stream live audio throughout the week- is it also possible to keep it playing when the iPhone is locked?
Thanks!!
Ben
Quick Edit: The same URLs work great in IOS Safari (locking and unlocking doesn't affect the audio. Just not in my app's webviews.
I did find my answer though, in case anyone comes here looking. Easiest thing in the world too- just add a row to the plist file labeled "Required Background Modes" and under that set item 0's value to "App plays audio". Voila!
Since the audio is in a UIWebView, I don't believe that you'd be able to play it in the background.
EDIT: I was wrong, adding "App Plays Audio" to the UIBackgroundModes will make it work even when audio is in a UIWebView.
Have you thought about just streaming the .mp3 file yourself? Should be easy enough and you'd be able to setup background streaming. To get you started, I'd check out Matt Gallagher's AudioStreamer class which easily allows you to stream .mp3 files and other audio files from the net: https://github.com/mattgallagher/AudioStreamer

Playing the multiple Audio files in different Views using single audio player instance in 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! :)

mp4 vs m3u8 format

I am trying to play a video in iPhone, which has m3u8 format. The video's link is parsed from an XML (so i cannot change it). I'm trying to play it with MoviePlayerController (set it on fullscreen, controlStyle is fullscreen too, set the presentModalViewController to the MoviePlayerController). After pressing the play button, the movie has only sound for a few seconds, no video screen, and the app crashes.
In this XML I have a different videolink, which contains mp4 format. Playing the video in the same mode (with MoviePlayerController and the settings...), it works fine. So: do you have any ideas what the problem is? If there is any encoding problems of m3u8? If it can be changed and how?
Thank you :)
Look the AVPlayerDemoPlaybackViewController class from this very useful open source control released by Peter Steinberger
https://github.com/steipete/PSPushPopPressView
Thanks again Peter!

Is there an easy way to stream a m3u in iPhone?

I can have a UIWebView with the .m3u file opened, which will go to the webview with a play button displayed, and that automatically goes to the quicktime player and starts playing the stream. But when I press the done button, it goes back to the UIWebView with a little play button in the middle, and from there you can go back to the previous screen (it was selected from a tableview). So I just want it to automatically load the quicktime player in the view. How can I do that?
An m3u file is nothing more than a text file listing MP3 (and / or other format) digital audio files to be interpreted by player software as a series of audio files to be played in succession. So my best guess (I am about to implement this myself, so I'll find out soon if it actually works that way) at going about this is:
read in m3u file
parse for stream URLs and store these
choose / let user decide which one to play
Implement streaming player like explained here.
There is no step 5. I hope.

Play an audio file and return back to the page

in my iPhone app, I have an UIWebView with some simple HTML links to audio files.
When the user opens such an audio file, media player plays it an leaves my
UIWebView with this screen:
alt text http://img.skitch.com/20090622-rnx614kynh8faecjmuiyec159b.jpg
How do I dismiss it after the audio file was played?
I've searched for UIWebView's delegates without finding something useful.
Mike, I've found a solution: Create a HTML page and embed your audio file the follwing way:
<embed src=”http://www.mypage.com/test.wav”>
This gives you an embedded mini player.
No, you can't dismiss that properly, or at least I couldn't figure out how to do it. So I just used the movie player for all my audio and video. It's a little more complex but it is much more flexible.