Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    81
    Thanks
    0
    Thanked 8 Times in 8 Posts

    quick lists for mvplayer

    You can use something like the code posted below to quickly build play lists for the mvplayer posted on this site.

    Code:
    <!doctype html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <style type="text/css">
    </style>
    <script type="text/javascript">
    $(function(){
    	$("#btn1").click(
    		function(){
    			dosearch();
    		}
    	);
    	$("#search").keyup(
    		function(event) {
    			if (event.keyCode == '13') {
    				event.preventDefault();
    				dosearch();
    			}
    		}
    	);
    });
    function dosearch(){
    	var searchurlwcback = "http://gdata.youtube.com/feeds/api/videos?q=[]&v=2&alt=jsonc&callback=parseme";
    	var searchurlwcback = "http://gdata.youtube.com/feeds/api/videos?q=[]&v=2&alt=jsonc";
    	searchurlwcback = searchurlwcback.replace("[]",($("#search").val()).replace(/ /g,"+"));
    	$.ajax({
    		url: searchurlwcback,
    		success: function(data) {
    			var items=parseInt(data.data.itemsPerPage);
    			if(items>0){
    				var vids = data.data.items;
    				var i=0;
    				var s = "";
    				for(var i=0;i<items;i++){
    					s+="[\""+vids[i].title+"\",";
    					s+="\"http://www.youtube.com/watch?v="+vids[i].id+"\",";
    					s+=vids[i].duration+"]\r\n";
    				}
    				var t = $('#search').val();
    				$('#ta1').val(items.toString() + "videos found\r\n\r\n"+t+"\r\n"+s);
    			}
    		}
    	});
    };
    </script>
    </head>
    <body>
    <input id="search" size="16" value="2010 music" /><button id="btn1">Search</button><br />
    <textarea id="ta1" rows="20" cols="140"></textarea>
    </div>
    </body>
    </html>
    mix and match the resulting arrays as you like, and feed them into the mvplayer as custom lists.
    Last edited by rdspoons; 11-20-2010 at 01:34 AM.

  • #2
    New Coder
    Join Date
    Jun 2009
    Posts
    81
    Thanks
    0
    Thanked 8 Times in 8 Posts
    Code update.
    JQuery Axaj used in original no longer works. No clue as to when it stopped. Live by the cdn, die by the cdn.

    Anyway, below is replacement code for Quicklist if interested. It uses a small xhlhttp routine that I've used for years - and remember: run the page locally.

    Code:
    <!doctype html>
    <html>
    <head>
    <title>
    Quicklist
    </title>
    <style type='text/css'></style>
    <script type="text/javascript">
    xmlhttp={
      	fnc:null,
      	load:function(url,fnc){
         		xmlhttp.starttime=(new Date()).getTime()
         		if(fnc==null){
           		if(xmlhttp.fnc==null){
             			alert("You need to add a callback function to the loadDoc call.")
             			return
           		}
           		else
             			fnc=xmlhttp.fnc;
         		}
         		else
           		xmlhttp.fnc=fnc
         		if(xmlhttp.fnc==null){
           		alert("No callback function was set");
           		return;
         		}
            	if (window.XMLHttpRequest){
                 	xmlhttp.request = new XMLHttpRequest();
                 	xmlhttp.request.onreadystatechange = xmlhttp.processReqChange;
                 	xmlhttp.request.open("GET", url, true);
                 	xmlhttp.request.send(null);
            	}else if (window.ActiveXObject){
                 	xmlhttp.request = new ActiveXObject("Microsoft.XMLHTTP");
                 	if (xmlhttp.request){
                     		xmlhttp.request.onreadystatechange = xmlhttp.processReqChange;
                     		xmlhttp.request.open("GET", url, false);
                     		xmlhttp.request.send();
                 	}
            	}
       	},
      	processReqChange:function(){
            	if (xmlhttp.request.readyState == 4){
                 	if (xmlhttp.request.status == 200){
             			xmlhttp.elapsedtime=(new Date()).getTime()-xmlhttp.starttime;
         				var t1 = xmlhttp.request.responseText;
         				if(t1){
               				xmlhttp.fnc(t1);
             			}
                 	} 
       			else{
                     		//alert("There was a problem retrieving the data:\n" + req.statusText);
           		}
         		}
       	}
    }
    
    function show(txt){
    	try{
    		var data;
    		eval("data = "+txt);
    		var items=parseInt(data.data.itemsPerPage);
    		if(items>0){
    			var vids = data.data.items;
    			var i=0;
    			var s = "";
    			for(var i=0;i<items;i++){
    				s+="[\""+vids[i].title+"\",";
    				s+="\"http://www.youtube.com/watch?v="+vids[i].id+"\",";
    				s+=vids[i].duration+"]\r\n";
    			}
    			var t = document.getElementById("search").value;
    			document.getElementById("ta1").value=items.toString() + "videos found\r\n\r\n"+t+"\r\n"+s;
    		}
    	}catch(e){
    		document.getElementById("ta1").value="ERROR: "+e.description+"\r\n"+txt;
    	}
    }
    
    function grabit(){
    	var searchurlwcback = "http://gdata.youtube.com/feeds/api/videos?q=[]&v=2&alt=jsonc";
    	var search = document.getElementById("search").value;
    	if(search!=""){
    		searchurlwcback = searchurlwcback.replace("[]", search.replace(/ /g,"+"));
    		document.getElementById("d1").innerHTML = searchurlwcback;
    		xmlhttp.load(searchurlwcback ,show);
    	}
    	else
    		alert("fail")
    }
    
    </script>
    </head>
    <body>
    <div id="d1"></div>
    <input id="search" value="byob" />
    <button onclick="grabit()">Grab It!</button>
    <textarea id="ta1" rows="20" cols="140"></textarea>
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •