Thursday, April 19, 2012

[YouTube-API] Re: main video player dont show

Anybody can help here?

thanks

On Apr 18, 5:13 pm, mt <michalon...@gmail.com> wrote:
> Hi Guys,
>
> i made youtube on facebook via youtube api + zend framework.
>
> all looked ok but one main issue- the main big window that suppose to
> show/play videonotshownfor some reason.
> can you please help me with that?
>
> thats the code (i took off the fb id):
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> TR/html4/strict.dtd">
> <html lang="he">
> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
> <head>
> <title>Un document multilingue</title>
> <style type="text/css">
> @charset "UTF-8";
> *
> {
>         border:0px;
>         margin:0px;
>         font-family: arial;}
>
> .title
> {
>         text-align: right;
>         text-decoration:none;}
>
> .title a
> {
>         font-family: arial;
>         font-size: 21px;
>         font-weight: bold;
>         color:#5678ab;
>         text-decoration:none;}
>
> .title a:hover
> {
>         text-decoration:underline;
>         color:#1874CD;}
>
> .title a:clicked
> {
>         text-decoration:none;
>         color:#5678ab;}
>
> .description
> {
>         color:#000000;margin-left:20px;
>         text-align:right;}
>
> .description a
> {
>         display:block;}
>
> .hrcls
> {
>         width:810px;
>         text-align:right;}
>
> .hrcls hr
> {
>         border:1px solid ;}
>
> </style>
> </head>
> <?php
> require_once 'Zend/Loader.php';
> Zend_Loader::loadClass('Zend_Gdata_YouTube');
> Zend_Loader::loadClass('Zend_Gdata_AuthSub');
> Zend_Loader::loadClass('Zend_Gdata_App_Exception');
>
> class YouTubeFacebook{
>
> public $pagesize = 10;
> public $video_count;
> public $fan_page_id = xxxxxxxxxx;
> public $youtube_channel = 'webdistortion';
>
> function echovideos( $video_id ){
>         $paging=$this->getPagingParam();
>         $videoFeed = $this->getFeedbyUser($this->youtube_channel, $paging);
>         $this->video_count =  $videoFeed->getTotalResults()->text;
>         $this->printVideoFeed($videoFeed, $video_id);
>         echo('<div style="width:450px;clear:both;margin-top:60px;text-
> align:right;font-size:10px;font-
> family:arial;color:#cccccc;"><span>Brought to you from </span><a
> style="font-size:10px;color:#333333;" href="http://www.facebook.com/
> boriginalltd">B! ORIGINAL</a></div>');
>
> }
>
> function getLikeButton( $url ){
> return '<fb:comments xid="'.$this->fan_page_id.'" returnurl="'.
> ($url).'" simple="1"></fb:comments>';
>
> }
>
> function echoMain( $videoEntry , $video_id){
>   $videoThumbnails = $videoEntry->getVideoThumbnails();
>   $mainImage= $videoThumbnails[1]["url"];
>   $videoFile = ($videoEntry->getFlashPlayerUrl());
>   if($video_id == -1){
>           echo '<div class="mainYouTube">';
>           echo '<fb:swf swfbgcolor="000000" imgstyle="border-width:3px;
> border-color:white;" width="455" height="280" swfsrc='.$videoFile.'
> imgsrc='.$mainImage.' />';
>           echo ($this->getLikeButton($videoFile) ); //generate a like button
>           echo '</div>';
>   }else{
>           echo '<div class="mainYouTube">';
>           echo '<fb:swf swfbgcolor="000000" imgstyle="border-width:3px;
> border-color:white;" width="455" height="280" swfsrc="http://www.youtube.com/v/'.$video_id.'" imgsrc='.$mainImage.' />';
>           echo ($this->getLikeButton($videoFile) ); //generate a like button
>           echo '</div>';
>   }
>
> }
>
> function printVideoFeed($videoFeed , $video_id)
> {
> $counter = 1;
>   foreach ($videoFeed as $videoEntry) {
>         if($counter==1 && ($this->getVideoID()=='') ){
>                 $this->echoMain($videoEntry,-1);
>         }else{
>                 if($counter==1){
>                 $this->echoMain($videoEntry,$video_id);
>                 }
>         }
>     $this->printVideoEntry($videoEntry);
>         $counter++;
>   }
>
> }
>
> function printVideoEntry($videoEntry)
> {
>   $videoThumbnails = $videoEntry->getVideoThumbnails();
>   $url_thumb = $videoThumbnails[1]["url"];
>   $video_id = $videoEntry->getVideoID();
>   echo '<div class="videoContainer">';
>         echo '<a href="index.php?Page='.$this->getPagingParam().'&video_id='.
> $video_id.'"><img src="'. $url_thumb .'" /></a>';
>         echo '<span>'.$videoEntry->getVideoTitle().'</span>';
>   echo '</div>';
>
> }
>
> function getFeedbyUser( $user, $video_count ){
>         $userVideosUrl = 'http://gdata.youtube.com/feeds/users/'.
>                      $user . '/uploads';
>     $yt = new Zend_Gdata_YouTube();
>     $ytQuery = $yt->newVideoQuery($userVideosUrl);
>     $ytQuery->setOrderBy('viewCount');
>         if($video_count!=0){
>                 $ytQuery->startIndex = ($video_count*5)+1;
>         }else{
>                 $ytQuery->startIndex;
>         }
>         $ytQuery->maxResults = 10;
>     $ytQuery->setFormat(5);
>     return $yt->getVideoFeed($ytQuery);
>
> }
>
> function getVideoID(){
>         $video_id = '';
>         if(isset($_GET['video_id']) && !empty($_GET['video_id']))
>                 $video_id = $_GET['video_id'];
>         return $video_id;
>
> }
>
> function getPagingParam(){
>         $Page = 0;
>         if(isset($_GET['page']) && !empty($_GET['page']))
>                 $Page = (int)$_GET['page'];
>         return $Page;
>
> }
>
> function generatePaging( $CurrentPage ){
> $page = $this->pagesize;
> $vids =  (int)$this->video_count;
> $totalPages = floor($vids / $page);
>                         for($i = 1; $i <= ($totalPages + 1); $i++) {
>                                 if(($i - 1) == $CurrentPage)
>                                         echo('<strong>' . $i . '</strong>');
>                                 else
>                                         echo('<a href="index.php?page=' . ($i - 1) . '">' . $i . '</a>');
>
>                                 echo("&nbsp;");
>                         }
>
> }
> }
>
> ?>
>   <style type="text/css">
>   .container{width:800px;}
>   .videoContainer{width:150px;padding:
> 10px;float:right;display:block;height:135px;}
>   .videoContainer img{width:150px;}
>   .videoContainer span{font-size:9px;font-family:Arial;line-height:
> 50%;text-align:right;}
>   .navigation{width:800px;display:block;clear:both;}
>   .mainYouTube{margin-bottom:50px;}
>   .logocontainer{display:block;height:150px;margin-top:15px;}
>   .connect_widget_sample_connections { display:none; }
>   .comment_body { display:none; }
>
>   </style>
>
> <div class="container">
>
>         <div class="logocontainer"><img src="http://www.---------------" /></
> div>
>
>         <?php
>         $instance = new YouTubeFacebook();
>         ?>
>
>         <?php
>         $instance->echovideos( $instance->getVideoID() );
>         ?>
> <div class="navigation">
>         <?php
>         $instance->generatePaging( $instance->getPagingParam() );
>         ?>
> </div>
>
> Thanks in advanced
> michael
> </div>
> </html>

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment