Solved

json for uploading videos

Posted on 2013-05-28
3
316 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks so much!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now