PSP Hacks - Forums

Go Back   PSP Hacks - Forums > Tech Talk > PC Programming

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2009, 07:20 AM
but2002's Avatar
but2002 but2002 is offline
PSP Veteran
 

Join Date: Oct 2007
Location: /root/media/sda1
Posts: 1,392
but2002 is on a distinguished road
Default Someone help me PLEASE!

I was running Windows 7, and this script worked wonderfully, but now that I'm back on XP. It's not.

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>&nbsp;-&nbsp;<a href=\""+getURL("sd")+"\">Download</a>]&nbsp;&nbsp;&nbsp;";
    }
    else {
        links = "[<a href=\""+cleanURL+"&Quality=Standard_Definition\">Standard Definition</a>&nbsp;-&nbsp;<a href=\""+getURL("sd")+"\">Download</a>]&nbsp;&nbsp;&nbsp;";
    }
    if (qual == "hq") {
        links += "[<b>High Quality</b>&nbsp;-&nbsp;<a href=\""+getURL("hq")+"\">Download</a>]&nbsp;&nbsp;&nbsp;";
    }
    else {
        links += "[<a href=\""+cleanURL+"&Quality=High_Quality\">High Quality</a>&nbsp;-&nbsp;<a href=\""+getURL("hq")+"\">Download</a>]&nbsp;&nbsp;&nbsp;";
    }
    if (qual == "hd") {
        links += "[<b>High Definition</b>&nbsp;-&nbsp;<a href=\""+getURL("hd")+"\">Download</a>]";
    }
    else if (isHDavail()) {
        links += "[<a href=\""+cleanURL+"&Quality=High_Definition\">High Definition</a>&nbsp;-&nbsp;<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");
}
I guess I should also say, that even with the "AutoStart" set to false, it's still automatically playing.
Does anyone know what's going on!?
__________________


Last edited by but2002; 08-02-2009 at 07:44 AM.
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:37 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©