![]() |
|
#1
|
||||
|
||||
|
Windows 7 has built in support for MP4, so I used this code to make YouTube videos load in an embedded WMP window, instead of that crappy flash player. Windows XP does not.. However, through codecs, I got it to work, now I'm having another issue. The Embedded player is resizing to the video, and won't stay the specified dimensions. Does anyone know how to fix? Here is my code for reference. Code:
// ==UserScript== // @name YouTube - NoFlash-Player // @namespace - // @description replaces Flash-Player // @include http://*.youtube.*/watch*v=* // @include http://youtube.*/watch*v=* // ==/UserScript== var conf = new Array(); // config start: conf["quality_default"] = "hd"; // "sd", "hq" or "hd" conf["autostart"] = false; conf["loop"] = false; conf["width"] = 640; conf["height"] = 480; // config end function getPlayer(qual) { url = getURL(qual); player = "<EMBED type=\"application/x-mplayer2\""; player += " width=\""+conf["width"]+"\" height=\""+conf["height"]+"\""; player += " src=\""+url+"\" autostart=\""+conf["autostart"]+"\" loop=\""+conf["loop"]+"\">"; player += "</EMBED>"; return player } function getURL(qual) { id = document.URL.split("v=")[1]; id = id.split("&")[0]; flashvars = document.getElementById("movie_player").getAttribute("flashvars"); valid = flashvars.split("&t=")[1]; valid = valid.split("&")[0]; downloadURL = "http://"+document.domain+"/get_video?video_id="+id+"&t="+valid; switch(qual) { case "sd": return downloadURL; break; case "hq": return downloadURL + "&fmt=18"; break; case "hd": return downloadURL + "&fmt=22"; break; default: return ""; } } function isHDavail() { flashvars = document.getElementById("movie_player").getAttribute("flashvars"); if (flashvars.indexOf("fmt_map=22/2000000/9/0/115")>=0) { return true; } else { return false; } } function getLinks(qual) { var theurl = window.content.location.href.toString(); cleanURL = window.location.href; cleanURL = cleanURL.replace(/&Quality=Standard_Definition/, ""); cleanURL = cleanURL.replace(/&Quality=High_Quality/, ""); cleanURL = cleanURL.replace(/&hd=1&Quality=High_Definition/, ""); var links; if (qual == "sd") { links = "[<b>Standard Definition</b> - <a href=\""+getURL("sd")+"\">Download</a>] "; } else { links = "[<a href=\""+cleanURL+"&Quality=Standard_Definition\">Standard Definition</a> - <a href=\""+getURL("sd")+"\">Download</a>] "; } if (qual == "hq") { links += "[<b>High Quality</b> - <a href=\""+getURL("hq")+"\">Download</a>] "; } else { links += "[<a href=\""+cleanURL+"&Quality=High_Quality\">High Quality</a> - <a href=\""+getURL("hq")+"\">Download</a>] "; } if (qual == "hd") { links += "[<b>High Definition</b> - <a href=\""+getURL("hd")+"\">Download</a>]"; } else if (isHDavail()) { links += "[<a href=\""+cleanURL+"&Quality=High_Definition\">High Definition</a> - <a href=\""+getURL("hd")+"\">Download</a>]"; } return links; } function replacePlayer(qual) { var theurl = window.content.location.href.toString(); if (theurl.search("hd=1") == -1) { } else { conf["width"] = 853; conf["height"] = 550; } document.getElementById('watch-player-div').innerHTML = getPlayer(qual)+"<br>"+getLinks(qual); } function getQuality() { url = document.URL; if (url.indexOf("Standard_Definition") >= 0) { return("Standard_Definition"); } else if (url.indexOf("High_Quality") >= 0) { return("High_Quality"); } else if ((url.indexOf("High_Definition") >= 0) && (isHDavail() == false)) { return("High_Quality"); } else if ((url.indexOf("High_Definition") >= 0) && (isHDavail() == true)) { return("High_Definition"); } else { if (conf["quality_default"] == "sd") { return("Standard_Definition"); } else if (conf["quality_default"] == "hq") { return("High_Quality"); } else if ((conf["quality_default"] == "hd") && (isHDavail() == false)) { return("High_Quality"); } else if ((conf["quality_default"] == "hd") && (isHDavail() == true)) { return("High_Definition"); } } } qualtiy = getQuality(); if (qualtiy == "Standard_Definition") { replacePlayer("sd"); } else if (qualtiy == "High_Quality") { replacePlayer("hq"); } else if (qualtiy == "High_Definition") { replacePlayer("hd"); } Does anyone know what's going on!?
__________________
![]() Last edited by but2002; 08-02-2009 at 07:44 AM. |
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|