Solved

json for uploading videos

Posted on 2013-05-28
3
343 Views
Last Modified: 2013-05-28
Hi,
I'm trying to grab some videos on a YouTube channel and display them on a webpage.

I can grab all the videos but I would like them all the same size with the title and description displayed.

The first one that gets uploaded has the title and description with them but the rest does not have that.

How can I get all the videos with their respective title and description?

I have included the code for better clarification.

Thanks!
video.txt
0
Comment
Question by:smfmetro10
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
Ahmed Hussein earned 500 total points
ID: 39202993
I attached the fixed code, you just forgot to add myOutput += '<p>' + entriesDescription + '<\/p>';
before he if statement inside the for loop.

<script type="text/javascript">

    function listVideos(data) {  
    var firstOutput="";  
    var entries = data.feed.entry;  
    var myOutput = '<ul>';  
    for (var i=0; i<data.feed.entry.length; i++) {    
    var entriesID=entries[i].id.$t.substring(38);    
    var entriesTitle=entries[i].title.$t;    
    var entriesDescription=entries[i].media$group.media$description.$t;
    var entriesThumbnail=entries[i].media$group.media$thumbnail[0].url;    
    myOutput += '<li><div class="entriestitle">' + entriesTitle + '<\/div>';    
    myOutput+='<iframe src="http://www.youtube.com/embed/'+entriesID+'?wmode=transparent&amp;HD=0&amp;rel=0&amp;showinfo=0&amp;controls=1&amp;fs=1&amp;autoplay="0" frameborder="0" allowfullscreen><\/iframe>';    
    myOutput += '<p>' + entriesDescription + '<\/p>';      
    if (i==0) {      
    firstOutput += '<div class="first">';      
    firstOutput += '<h2>' + entriesTitle + '<\/h2>';      
    firstOutput += '<iframe src="http://www.youtube.com/embed/'+entriesID+'?wmode=transparent&amp;HD=0&amp;rel=0&amp;showinfo=0&amp;controls=1&amp;autoplay="0" frameborder="0" allowfullscreen><\/iframe>';      
    firstOutput += '<p>' + entriesDescription + '<\/p>';  
    myOutput += '<p>' + entriesDescription + '<\/p>';
    firstOutput += '<\/div>';      
    document.getElementById('myplayer').innerHTML=firstOutput;

    }  

    }  
    document.getElementById('videolist').innerHTML = myOutput;  
    myOutput = + entriesDescription + '<\/ul>';
    }
    </script>

Open in new window


~AG
0
 
LVL 4

Expert Comment

by:Ahmed Hussein
ID: 39203004
Or try this one, it makes the list looks like the first video..

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>

    <style type="text/css">

    #videogroup 
    {    
    width: 100%; 
    }  
    iframe {    
    width: 90%;    
    padding: 5%; 
    }
    #myplayer .first iframe {   
    width: 100%;    
    padding: 0;  
    }    
    #videolist ul {    
    margin: 0;    
    padding: 0;    
    list-style: none;  
    }   
    #videolist li {    
    width: 50%;    
    float: left;    
    border: none;    
    position: relative;  
    }   
    #videolist li .entriestitle {    
    padding: 0 5px;    
    position: absolute;    
    left:80%;    
    top:20%;    
    display: none;  
    }    
    #videolist li:hover .entriestitle {    
    display: block;    
    width: 100%;    
    background: rgb(119, 25, 51);    
    border-radius: 10px;    
    color: #FFF;    
    padding: 10px;    
    opacity: .9;    
    z-index: 100;    
    right: 0;  
    } 
    </style>
    <script type="text/javascript">

    function listVideos(data) {  
    var firstOutput="";  
    var entries = data.feed.entry;  
    var myOutput = '<ul>';  
    for (var i=0; i<data.feed.entry.length; i++) {    
    var entriesID=entries[i].id.$t.substring(38);    
    var entriesTitle=entries[i].title.$t;    
    var entriesDescription=entries[i].media$group.media$description.$t;
    var entriesThumbnail=entries[i].media$group.media$thumbnail[0].url;    
    myOutput += '<li><div class="entriestitle">' + entriesTitle + '<\/div>';
   
    myOutput += '<p>' + entriesDescription + '<\/p>';      
    
    myOutput += '<div class="first">';      
    myOutput += '<h2>' + entriesTitle + '<\/h2>';
     myOutput+='<iframe src="http://www.youtube.com/embed/'+entriesID+'?wmode=transparent&amp;HD=0&amp;rel=0&amp;showinfo=0&amp;controls=1&amp;fs=1&amp;autoplay="0" frameborder="0" allowfullscreen><\/iframe>';          
    myOutput += '<p>' + entriesDescription + '<\/p>';  
    myOutput += '<\/div>';      

    
    if (i==0) {      
    firstOutput += '<div class="first">';      
    firstOutput += '<h2>' + entriesTitle + '<\/h2>';
    firstOutput += '<iframe src="http://www.youtube.com/embed/'+entriesID+'?wmode=transparent&amp;HD=0&amp;rel=0&amp;showinfo=0&amp;controls=1&amp;autoplay="0" frameborder="0" allowfullscreen><\/iframe>';      
    firstOutput += '<p>' + entriesDescription + '<\/p>';  
    myOutput += '<p>' + entriesDescription + '<\/p>';
    firstOutput += '<\/div>';      
    document.getElementById('myplayer').innerHTML=firstOutput;

    }  

    }  
    document.getElementById('myplayer2').innerHTML = myOutput;  
    myOutput = + entriesDescription + '<\/ul>';
    }
    </script>

    <title></title>
</head>

<body>
    <div id="videogroup">
        <div id="myplayer"></div>

        <div id="myplayer2"></div>
    </div><script type="text/javascript" src="http://gdata.youtube.com/feeds/users/doctorscompany/uploads?alt=json-in-script&callback=listVideos&max-results=16">
</script>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:smfmetro10
ID: 39203024
Thanks so much!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question