Is it possible to change Youtube Player parameters dynamically? - javascript

I am fiddling with Youtube API for my project, with the iFrame API in particular. And what I want to do is to show the player controls only when it is playing, not when it is stopeed or paused. I've searched through all the API for this feature, but it seems it is possible to change the player's appearance only by destroying at and creating a new one.
So, the question is, is it true? Or can I still change the player somehow?
Thank you!

I am 99% sure that you can only do this by "destroying" it and starting again. As you said there is no mention of it in the docs and the Parameters are sent on load, so you would have to resend them somehow, and not allow the reply back to change the video.
The only thing I suggest, is could you using the API trace what time in the video the change occurs, then reload the page with the new params and start the video where you left off?

Related

How does youtube use ajax

If you go visit a YouTube video and then click another video ( e.g a related video ) you see that the page is not entirely refreshing, Only the main video and related videos change, The rest of the page remains as it is.
I was wondering how they do that, If it's AJAX then why is the URL updating?
I've seen this technique on some other famous websites too , I was wondering how this works?!
You can change the URL without reloading the page, if the browser supports it.
Combined this with Ajax and you will see the behavior you are seeing.

YouTube controls/logo and loop

I know that i'm asking 2 questions but I'm looking for a simple solution for apparently a simple thing.
I want a video from youtube to loop and to show no controls/title/logo.
This is what i found so far.
For the loop : youtube recommends setting loop=1 and playlist=video_id. It works and it doesn't in the same time. Why, because the video is reloading over and over again, a loading screen appears every time the video is loaded, it takes so much bandwidth.
I found a website endlessvideo.com , it works so smooth but i don't know how they do it.
And for the controls and logo, i want them hidden. If i'm using modestbranding=1 and controls=0, a title appears.
If i'm adding showinf=0, the logo appears on mouseover the video.
Is there a way to override this?
Thank you.
Add below options to your link
src="//www.youtube.com/embed/VIDEO_ID?
iv_load_policy=3&
loop=1&
playlist=VIDEO_ID&
controls=0"
iv_load_policy setting the parameter's value to 1 causes video annotations to be shown by default, whereas setting to 3 causes video annotations to not be shown. The default value is 1.
loop setting the parameter's value to 1 will create a loop, default (stop at the end) value is 0.
controls this parameter indicates whether the video player controls are displayed. For IFrame embeds that load a Flash player, it also defines when the controls display in the player as well as when the player will load. Set its value to 0 to not display controls in the player. For IFrame embeds, the Flash player loads immediately.
Source

How can I create a player that continues playing on all pages?

The thing that I want to know is how to create a frame around the site that stays constant and at the same time and change the url in the address bar depending on the actual page being shown. It needs to be able to have an audio element that plays nonstop even if you go to another page on the server.
Pitchfork Website, the player can be seen in the upper righthand corner.
Swapping out content and then updating the URL sounds like a pattern that Mark Pilgrim goes over in http://diveintohtml5.info/history.html
With a little AJAX you can update your content, history.pushState() allows you to change the URL, and then add an event listener to listen to the popstate event (when the user navigates backwards).
This doesn't really give much guidance as to how you should structure your page or AJAX calls but hopefully it gives you an idea of the general concept.
If I understand you, you can include your resource as a template to your site (include it in every page, while taking into account the width and length of your main frame and the resource's size).

Getting a flash video on a new page load at position it was at on the last page

I have a an unobtrusive flash video looping in the background of a website, it is not essential to navigation - it is purely cosmetic.
The flash video loops every 30 seconds.
As this video is on all pages, it jumps back to the start when a new page is loaded.
Is there an actionscript / javascript way to get it to remember the position it got to on the old page so it can start there on the new page?
I do know that this can be accomplished by loading the flash movie in a frame as well as by having the subsequent pages load the contents in AJAX but I was hoping not to go down this route.
I have seen other people ask the question and allude to the solution but they only posted that they got it to work without saying how.
Thank you.
Flash SharedObject would help you. The link below shows how to use it.
SharedObject
You have to write currentframe of video to the sharedobject, and when it show up again get sharedobject and read the value for currentframe.

Automatic Javascript Video Pop-Up

I need a video to automatically pop up, ideally in a lightbox. It needs to automatically pop up when a user first visits the page, play the video then close. I also need a button to play again if needed. I also only want this video to play the first time a person visits the homepage, so when you navigate back to the homepage it will not play again.
Diodeus has a good point. The stack overflow community is to help specific questions, not to write programs for each other.
You have a number of needs, and I will try to help you sort them out:
Embedded Video
Lightbox
Automatic Popup
Stored State
Embedding videos can be a challenge. Quickly searching TheGoogle (embed a video) gives me this link:
http://www.hunlock.com/blogs/Everything_You_Ever_Needed_To_Know_About_Video_Embedding
I did not read it, but the point is you can find many resources for video embedding.
Lightbox
There are many lightbox scripts ( http://www.lokeshdhakar.com/projects/lightbox2/ ), you will have to slog through them to find one that you like.
Automatic Popup
If you're using jQuery I would suggest the jQuery.ready function.
Stored State
To see if a user has visited the homepage before, I would suggest setting a cookie. http://www.quirksmode.org/js/cookies.html

Categories

Resources