Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

json for uploading videos

Posted on 2013-05-28
3
Medium Priority
?
362 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

876 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