Solved

json for uploading videos

Posted on 2013-05-28
3
334 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery get each value 2 30
ASP.net Show "please wait " message as page loads 2 39
javascript comparing two dates 3 17
Checkout Page Input Field not aligned 1 20
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

813 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

10 Experts available now in Live!

Get 1:1 Help Now