Youtube Prevent Autoplay

By Yansky Last update Nov 16, 2008 — Installed 32,563 times.

Archived Comments (locked)

in
Subscribe to Archived Comments 29 posts, 12 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
JoeSimmons Scriptwright

BTW, do you know why < blockquote > doesn't seem to be working in comments anymore?
It works, it's just invisible.
Install my script here and it makes them look nice. Also a faster Stylish version here.

Btw avg, I like the old player because you can click anywhere on the player to start it... the new one you have to click right on the button. Also I like the seeking more on the old one, it seems more precise.

 
Avindra V.G. Scriptwright

testing

it seems to work, but the "greenish" css is completely gone.

 
Yansky Script's Author

@avg - Thanks, that works really well. I've updated the script with your code.

BTW, do you know why < blockquote > doesn't seem to be working in comments anymore?

 
Avindra V.G. Scriptwright

Even shorter code is: USES THE PLAYER ON THE PAGE

with(document.getElementById('movie_player'))
{
	setAttribute("flashvars","autoplay=0&"+getAttribute("flashvars"));
	src+="#";
}

this allows you to use the new player as well, instead of switching to the less attractive older one.

 
Avindra V.G. Scriptwright

Ok I tested this code and it works fine: USES THE OLD PLAYER

	  with(document.getElementById('movie_player'))
	  	{
	  	src="/player2.swf?"+getAttribute("flashvars");
		setAttribute("flashvars","iurl=http%3A//img.youtube.com/vi/"+/v=([^#&]+)/.exec(document.URL)[1]+"/default.jpg");
		src+="#";
		}

 
Avindra V.G. Scriptwright

did you try out my other code suggestion? i tried it and it works on this end.

 
Yansky Script's Author


For example, wouldn't :
document.getElementById('movie_player').src='/player2.swf'
do the trick?

I tried it out but it didn't seem to work for me.

 
Avindra V.G. Scriptwright

This script can be shorter:

var $=function(x) {return document.getElementById(x)}, 
    fvars = $('movie_player').getAttribute('flashvars'),
  getArg=function(arg) {
     return (new RegExp(arg+"=([^&#]+)").exec(fvars)||[,''])[1];
  },
 vidID = getArg('video_id'), l=getArg('l'), t = getArg('t'); 

$((/\/user\//.test(document.URL) ? 'profile' : 'watch') + '-player-div').innerHTML = '<embed id="movie_player" flashvars="&rs=1&sn=1&hl=en&iurl=http%3A//img.youtube.com/vi/'+vidID+'/default.jpg"'+
'type="application/x-shockwave-flash" wmode="transparent" src="/player2.swf?video_id='+vidID+'&t='+t+'&l='+l+'"'+
'height="395px" width="480px"></embed>';

Haven't tested it at all, but I'm assuming it should work.

But one question: Why don't you just port the flashvars directly over, instead of extracting bits and pieces? Better yet, why don't you just search for the <embed>, and change the src directly?

For example, wouldn't :

document.getElementById('movie_player').src='/player2.swf'

do the trick? I might be wrong.

 
Yansky Script's Author

@ekbworldwide & wolssiloa - I've updated it to work on the profile page.

 
wolssiloa User

I second ekbworldwide's idea. Videos on a user's profile should also not automatically play.

 
ekbworldwide Scriptwright

Could you add the ability to stop profile videos from auto-starting?

 
JoeSimmons Scriptwright

Nice. Could you possibly make a script that will just pause the video when it starts, so it loads but doesn't play right away? In other words, could you make this script have the video load but not play yet?

 
xee User

Very helpful script indeed! Thanks a lot, mate!

 
Paweł Solorz User

this script doesn't work with opera 9.51

 
wolssiloa User

Awesome script, very useful. Thanks Yansky!

 
Yansky Script's Author

Updated

 
moryabdi Scriptwright

thank you work great...

 
Yansky Script's Author

@Daniel Silva: Try this script instead: http://userscripts.org/scripts/show/13955

 
Daniel Silva User

Hi, developers.

I would like to make a suggestion about YT Prevent Autoplay:

When this feature is marked/enabled, the Prevent Autoplay works fine, but I will be thankful if the video continues loading automatically, like paused or something...

Free Hugs,
Daniel, from Brazil.

 
Yansky Script's Author

@spacemanspiff: I've altered the script so it wont open in a new window when you click on the big arrow in the middle of the video to play it.

The script should also work now even if embedding is disabled.

 
spacemanspiff User

hi yansky, it's a great script here
just have one annoyance though,
when i click on the big arrow in the middle of the video to start it, it opens it up in another tab...
ie. i'm being forced to use the small arrow in the bottom left..

not a huge problem, but still a bit of an annoyance

any way to fix that?

 
Yansky Script's Author

An alternative to my script is this one by lazyttrick: http://userscripts.org/scripts/show/7917

 
bisley User

Yeah, thank you Yansky.

 
Yansky Script's Author

Bisley, I think it should be ok now.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel