YouTube Player Replacement

Subscribe to YouTube Player Replacement 11 posts, 6 voices

Geoff S. User

I know YouTube has been done to death (The same thing over and over) but i have something reasonably unique i'd like to try.

I looked at Michael Sheldon's FLV Player userscript [from http://www.mikeasoft.com/], which takes the youtube video player and replaces it with a pure <embed> tag, but i'd like to use jeroen wijering's flash player as the replacement.

The flash player needs to have a .flv in it's "&file=" flashvar.

So i have removed the <embed> code from the orignal script and the following is the result (Not including header info - it's running on http://youtube.com/* and http://www.youtube.com/*)

[Code]
var reg = /&t=[\w-]{10,}/ig
var html = document.getElementById("interactDiv").innerHTML;
extra = reg.exec(html);
if (extra) {
var flashplayer = document.getElementById("playerDiv");
var title = document.getElementById("video_title");
var embedded = document.createElement("div");
URL = window.location.href;
var code = URL.substr(URL.lastIndexOf('v=')+2);
if(code.indexOf('&') != -1) {
code = code.substr(0,code.indexOf('&'))
}
flvURL = 'http://youtube.com/get_video?video_id=' + code + extra[0];
embedded.innerHTML = "<e src="http://www.jeroenwijering.com/embed/mediaplayer.swf" height="340" width="455"></e>";
title.parentNode.insertBefore(embedded, title.nextSibling);
flashplayer.parentNode.removeChild(flashplayer);
}
[/code]
(Spaces added to embed to stop it embedding in the page)

The original script work fine, and does it's job well, however, the code above doesn't even remove the old player (Which, from what i know of coding user scripts, it really should)

My number one suspicion is that the /s in the URLs are causing the rest of the script to be commented out and therefore not run, but i'm not very good at this stuff.

If someone could help, that'd be great.</embed></embed>

 
Joel H Scriptwright

Here's one good way to help yourself solve this problem:
1. go to the page, with the script running.
2. go to tools-> javascript console
3. any errors there you don't understand, google.

-Joel

 
alien_scum Scriptwright

A cursory glance tells me that this won't work

embedded.innerHTML = "<e src="http://www.jeroenwijering.com/embed/mediaplayer.swf" height="340" width="455"></e>"; 

as you haven't escaped the qotes so they are effectively eding the string. If you wan't to use " in your string use ' to start it. i.e.
embedded.innerHTML = '<e src="http://www.jeroenwijering.com/embed/mediaplayer.swf" height="340" width="455"></e>'; 

 
Geoff S. User

Hm.. thanks for the tips guys.

@Joel H: There were no errors from that page in the JS console. I'd already tried.

@alien_scum: I will check it works when i get to the PC it's on. Thanks.

 
Geoff S. User

Cool, the embed now works. Just need to get the rest working.

If someone knows a way (Using javascript, of course) to get the exact URL of a youtube video, then that'd be awesome. The current script only gets the URL to a redirect page (Which the player can't handle properly).

 
deodrus Scriptwright

Hi Geoff.

Can't you use the javascript in Lazyttrick's "Download Youtube Video II" to get the FLV file?

I know it says "get_video" instead of the original "[filename].FLV" format... but will that pose a problem? I don't know much javascript, but I hope that can help. I'm highly interested in what you're attempting to do. If you're successful, I'd like to do the same. I don't like the Youtube Flash Player.

BTW, is it possible to skin "Jeroen Wijering's FLV Player" ? I love his fullscreen mode! Is it open-source?
I'd like to attempt to skin it to look sleek like the Veoh Player ==> www.veoh.com

 
deodrus Scriptwright

Oops, I forgot to include the link to Lazyttrick's script: http://userscripts.org/scripts/show/8177

 
Geoff S. User

Sorry i've been busy. I don't think it likes the get_video urls. That always seems to make the player sit there at te loading animation. I will have a look though.

 
Geoff S. User

Boomvid is nowhere near what i want. I jsut want to replace the player with a more full-featured one.

I haven't looked at this in a while.

 
Descriptor Scriptwright

Yea, well, that looks like spam to me, I wouldn't touch a spam url with a ten-foot html tag.

Anyway, I don't think that "Download Youtube Video II" will do anything different, if you're getting a redirect you need to use GM_xmlhttpRequest to get the Location response header.

 
sizzlemctwizzle Scriptwright

Jeroen Wijering's FLV Player is opensource. Can't you just go in, remove the flv only parameter and recompile the fla?

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