When my embed youtube video finished I can't play it again? - iphone

I have a working webview in Titanium with an embeded youtube video. The video plays nice, I can stop it, resume it and so on. But when the video plays to the end and I press "done". The webview goes black with the text: YouTube. Nothing else. I would like there to be the same thumb and playbutton as before I played the video.
My embeded code looks like this:
html:'<html><head></head><body style="margin:0"> <embed id="yt" src="'+tubeURL+'" type="application/x-shockwave-flash" width="150" height="113"></embed></body></html>',
I've googled this problem for days now. I hope someone can help me here.
Cheers
//Martin
EDIT: This solved it. Put &controls=1&rel=0 in the end of the URL.

YouTube players can be embedded in a web page using either an < iframe> tag or an < object> tag.
By appending parameters to the SWF or IFrame URL, you can customize the playback experience in your application. For example, you can automatically play videos using the autoplay parameter or cause a video to play repeatedly using the loop parameter or in your case hide or show controls.
controls
Values: 0, 1, or 2. Default is 1. This parameter indicates whether the video player controls will display. For AS3 players, it also defines when the Flash player will load:
controls=0 – Player controls do not display in the player. For AS3 players, the Flash player loads immediately.
controls=1 – Player controls display in the player. For AS3 players, the Flash player loads immediately.
controls=2 – Player controls display in the player. For AS3 players, the Flash player loads afer the user initiates the video playback.
The correct answer for your question would be controls=2.
SOURCE INFO: https://developers.google.com/youtube/player_parameters#controls

Related

AVPlayer can only play up to 16videos

I have implemented a pager in which each page shows the user a video. Each page has his own AVPlayer instanciated.
Everything work as expected until the 17th video.
I read a lot regarding this issue. It appears that this is an Apple limitation, where an app is limited to display the player layers.
The solution I tried (several sources says it fixes the issue) is to remove the player layer from its parent and set the player to Nil. So each time a page disappears (didDisappear) I call:
// player and playerLayer are init at viewWillAppear().
player?.pause()
player = nil
playerLayer?.removeFromSuperlayer()
That does not change anything... I am still limited to 16 video plays.
Thus, my question is:
1) Why this behavior? Is it really expected?
2) How do Musical.ly or Snapchat achieve to switch infinitly between videos?
Thanks a lot for your help.
Try to change your code with
player?.pause()
player?.replaceCurrentItem(with: nil)
playerLayer?.removeFromSuperlayer()
player = nil
setting nil item into player will stop playing.
1) Yes, it's expected behavior for AVPlayer. It was designed for video players creation or for displaying ads videos in games, but not for videos walls like has Instagram or similar services.
2) It's simple. They are not using AVPlayer. For your purpose you can use combination of AVAssetReader and AVSampleBufferDisplayLayer

simple custom video player for ios

I am developing an app in which I wanna show the tutorial on how to use the app. For that need a custom video player which should look simple with a single play/pause button, a seeker and a stop button.
I have tried some video players like "videoplayerkit". To use this videoplayerkit I have to install cocoapods(libpods.a). It would be very helpful if anyone help me with a custom third party video player that satisfies my need. In short I need something like this in the picture below
You can try out an example app I created if you would like to see an example of a custom movie player, the Xcode project is at AVSync. This movie player looks exactly like the default iOS movie player, but you can have a look at the code to see how a custom set of controls can be made to control a movie player underneath. This example sits on top on a custom movie library, but the basic idea of creating your own controls and having them submit actions is the same no matter how you implement it.

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?

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

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.

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.