UIWebView intercept "setting movie path:" from javascript audio player - iphone

In iOS 4, I've got a page loaded in a UIWebView with a javascript audio player. I did not create this player, it is owned by a third party, so I can't tinker with it. When I click the play button, I see an NSLog printout like the following:
setting movie path: http://data.myaudio.com/thefile.mp3
My question is, what is getting it's movie path set and how do I intercept it? The audio will continue to play until I create another UIWebView, or use the built in audio controls accessible by an iPhone home button double tap, or close the app. I can't intercept the path with shouldStartLoadWithRequest:, the javascript function audio.play() appears to call some built in player directly. I'd like to control where and how the audio is being played, but short of parsing the HTML for any <audio> tags, I can't figure out how to grab that path and point it somewhere other than the default.

UIWebView is essentially a wrapper for WebKit. Apple does not want you to touch anything more about it than is provided by the existing delegate methods.
That being said, you can modify the DOM of any loaded document by injecting JavaScript. This way you could also modify the audio.play to not do anything and instead get the URL to play with your own player that you can control.

Related

jPlayer doesn't play audio file automatically in iPad

I am trying to play audio file using jPlayer in iPad. It works fine in Safari on my local PC but when I tried to open it in my iPad it doesn't play audio automatically.
Please help me.
Thanks
You may have to initialize jPlayer on user action in Mobile Safari.
The first time a media element is played must be initiated by a user gester. ie., The user must click the play button. This affects the operation of a jPlayer("play") in the ready event handler. The browser will ignore the command. jPlayer will simply wait until the user presses the play button.
Once the first gesture has been received, JavaScript code is then allowed to do whatever you want with the media element. Note that a jPlayer media player instance uses a audio and a video element. Each require their own gesture.
As a hack, you could possibly add a handler for a touch event on an outer container element (or body) and initialize any jPlayer instances that you want.
Ref: http://www.jplayer.org/latest/developer-guide/#jPlayer-known-issues-event-driven
Do you mean it doesn't play automatically? Because if it does, I don't see what your problem is.
Check if you have entered the correct path for option swfPath.

Play a video whose URL is not known in advance - without reload - without extra tab

I have lots of buttons on a web page. Depending on which one is clicked, I want to play a different video.
A large number of <video> elements doesn't seem to work particularly quickly or reliably.
So far, I have tried to:
Create and play() the video element dynamically, after an image is clicked:
var video = document.createElement('video');
video.src = 'video.mp4';
document.body.appendChild(video.play);
video.play();
This works on iOS 4, but not on iOS 3.
Create the video element before, and just change the src.
Doesn't work either.
It seems like the video object must have already done "it's thing", before it can be played.
Use window.open() to open the video URL.
This will cause an annoying new tab to open, which will remain open after playback has completed.
Set window.location
This will cause the current page to be reloaded after playback has completed, which I'm trying to avoid.
Any more ideas?

How to record a video automatically in Iphone app without user interaction

I am working an iphone app that needs to record a vedio automatically.
I used mobile coreservices framework and using that. I made it to came into video mode and clicking on record option its start capturing a vedio. But I want it automatically that is.. I should able to record a video without clicking on record option. That is when video mode comes up its automatically start record video.
Could any one help?
You can look at UIImagePickerControllers startVideoCapture method which is used to start taking video from the camera, this is to be used when you arent using the camera standard controlors and you provide and overlay view. Here is a reference UIImagePickerCOntroller ref. If this is not enough for you, you might want to look into AVFoundation framework which gives you a lot more control over video capturing process...hope that helps

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.