Embed vimeo,youtube new and youtube old videos


function getParm(url, base) {
        var re = new RegExp("(\\?|&)" + base + "\\=([^&]*)(&|$)");
        var matches = url.match(re);
        if (matches) {
            return(matches[2]);
        } else {
            return("");
        }
    }
	
function parseVideoURL(url) {
    
    
    
    var retVal = {};
    var matches;
    
    if (url.indexOf("youtube.com/watch") != -1) {
        retVal.provider = "youtube";
        retVal.id = getParm(url, "v");
    } else if (matches = url.match(/vimeo.com\/(\d+)/)) {
        retVal.provider = "vimeo";
        retVal.id = matches[1];
    }
	 else if(url.indexOf("/youtu.be/") != -1)
	 {
	   retVal.provider = "youtube";
	   
	   retVal.id = url.split("/")[3];
	   alert(url.split("/")[3]);
	 }
    return(retVal);
}

function createit()
{
var name= $("#nameofalbum").val();
var link1 = $("#location").val();
var details = $("#details").val();
var video = parseVideoURL(link1);
$.ajax({
     url:"createvideo.php",
	 type:"post",
	 data:{'name':name,'link':video.id,'video_from':video.provider,'details':details},
	 success:function(da){
	         $("#uppics").show(0);
			if(video.provider =="youtube")
				{
			  var row = "<tr id='"+da+"'><td>" + name + "</td><td></td><td>"+ details+"</td><td><img src='images/pencil.png' height='40px' width='40px'></td><td><img src='images/denied.png' height='40px' width='40px'></td></tr>";
				}
			if(video.provider =="vimeo")
			{
			var row =  "<tr id='"+da+"'><td>" + name + "</td><td></td><td>"+ details+"</td><td><img src='images/pencil.png' height='40px' width='40px'></td><td><img src='images/denied.png' height='40px' width='40px'></td></tr>";
			}
			$("#albumbody").append(row);
               $("input[type=text]").val(""); 
    }
});
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s