Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

json for uploading videos

Posted on 2013-05-28
3
Medium Priority
?
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

670 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