Esempio n. 1
0
 /**
  * Function is used to display palyer and video information
  *
  * @param array $arguments          
  * @return unknown number string
  */
 function hdflv_sharerender($arguments = array())
 {
     global $wpdb, $current_user;
     /** Variable initialization for ContusVideoDetailView */
     $output = $videourl = $imgurl = $vid = $playlistid = $homeplayerData = $rate = $no_views = $windo = $post_date = '';
     $video_playlist_id = $videoId = $hitcount = $show_posted_by = $show_added_on = $show_social_icon = $ratecount = $videodivId = 0;
     $fetched = array();
     /** Get random number to attach */
     $videodivId = rand();
     /** Check admin logged in */
     $isAdmin = absint(filter_input(INPUT_GET, 'admin'));
     /**  Query to get settings data from db */
     $configXML = getPluginSettings();
     /** Generate flashvars detail 
      * for player starts here */
     $flashvars = $pluginflashvars = 'baserefW=' . home_url();
     /**  Get width from settings */
     $width = $configXML->width;
     if (isset($arguments['width']) && !empty($arguments['width'])) {
         /** Get width from short code */
         $width = $arguments['width'];
     }
     /** Get height from settings */
     $height = $configXML->height;
     if (isset($arguments['height']) && !empty($arguments['height'])) {
         /** Get height from short code */
         $height = $arguments['height'];
     }
     /** Get playor colors, posted by, social icon, rss icon 
      * and related videos count from settings object */
     $player_color = unserialize($configXML->player_colors);
     $show_posted_by = $player_color['show_posted_by'];
     $show_social_icon = $player_color['show_social_icon'];
     $show_rss_icon = $player_color['show_rss_icon'];
     $number_related_video = get_related_video_count();
     /** If related video is not given in settings page,
      * then assign default value 100 */
     if (empty($number_related_video)) {
         $number_related_video = 100;
     }
     /** Get show added on option from settings*/
     if (isset($player_color['show_added_on'])) {
         $show_added_on = $player_color['show_added_on'];
     }
     /** Send report for video */
     if (isset($arguments['id'])) {
         /** Get video id from short code */
         $videodivId .= $arguments['id'];
         $vid = $arguments['id'];
     }
     if (!empty($vid)) {
         $wp_user = wp_get_current_user();
         $wp_user_id = $wp_user->ID;
         /** Call function to get video details  */
         $homeplayerData = $this->short_video_detail($vid, $number_related_video);
         $fetched[] = $homeplayerData;
     }
     /** Store video details in variables */
     if (!empty($homeplayerData)) {
         /** Get video detials from model */
         $videoUrl = $homeplayerData->file;
         $videoId = $homeplayerData->vid;
         $video_title = $homeplayerData->name;
         $video_slug = $homeplayerData->slug;
         $video_file_type = $homeplayerData->file_type;
         $video_playlist_id = $homeplayerData->playlist_id;
         $description = $homeplayerData->description;
         $tag_name = $homeplayerData->tags_name;
         $hitcount = $homeplayerData->hitcount;
         $uploadedby = $homeplayerData->display_name;
         $uploadedby_id = $homeplayerData->ID;
         $ratecount = $homeplayerData->ratecount;
         $rate = $homeplayerData->rate;
         $post_date = $homeplayerData->post_date;
         $video_thumb = getImagesValue($homeplayerData->image, $video_file_type, $homeplayerData->amazon_buckets, '');
     }
     /** Get playlist id from short code */
     if (isset($arguments['playlistid'])) {
         /** Get video id */
         $videodivId .= $arguments['playlistid'];
         /** Get playlist id */
         $playlistid = $arguments['playlistid'];
         /** Set flash vars */
         $flashvars .= '&mtype=playerModule';
     }
     /** Check view is from admin */
     if (!empty($isAdmin)) {
         $flashvars .= '&adminview=true';
     }
     /** Generate flashvars detail for player starts here */
     if (!empty($playlistid) && !empty($vid)) {
         $flashvars .= '&pid=' . $playlistid . '&vid=' . $vid;
     } elseif (!empty($playlistid)) {
         $flashvars .= '&pid=' . $playlistid . '&showPlaylist=true';
         $playlist_videos = $this->_contOBJ->video_pid_detail($playlistid, 'detailpage', $number_related_video);
         /** Get video details based on the playlist id */
         if (!empty($playlist_videos)) {
             $videoId = $playlist_videos[0]->vid;
             $video_playlist_id = $playlist_videos[0]->playlist_id;
             $hitcount = $playlist_videos[0]->hitcount;
             $uploadedby = $playlist_videos[0]->display_name;
             $uploadedby_id = $playlist_videos[0]->ID;
             $ratecount = $playlist_videos[0]->ratecount;
             $rate = $playlist_videos[0]->rate;
             $fetched[] = $playlist_videos[0];
         }
     } else {
         if ($this->_post_type !== APPTHAVIDEOGALLERY && $this->_page_post_type !== APPTHAVIDEOGALLERY) {
             $flashvars .= '&vid=' . $vid . '&showPlaylist=false';
         } else {
             $flashvars .= '&vid=' . $vid;
         }
     }
     /** Set flashvars based on the short code arguments */
     if (isset($arguments['flashvars'])) {
         $flashvars .= '&' . $arguments['flashvars'];
     }
     if (!isset($arguments['playlistid']) && isset($arguments['id']) && $this->_post_type !== APPTHAVIDEOGALLERY && $this->_page_post_type !== APPTHAVIDEOGALLERY) {
         $flashvars .= '&playlist_autoplay=false&playlist_auto=false';
     }
     /** Generate flashvars detail for player ends here */
     $player_not_support = __('Player doesnot support this video.', APPTHA_VGALLERY);
     $htmlplayer_not_support = __('Html5 Not support This video Format.', APPTHA_VGALLERY);
     $output .= ' <script> var videoPage;                      
               videoPage = "' . $this->_mPageid . '"; </script>';
     if (isset($arguments['title']) && $arguments['title'] == 'on') {
         $output .= '<h2 id="video_title' . $videodivId . '" class="videoplayer_title" ></h2>';
         $pluginflashvars .= $flashvars .= '&amp;videodata=current_video_' . $videodivId;
     }
     /** Player starts here */
     $output .= '<div id="mediaspace' . $videodivId . '" class="videoplayer">';
     $mobile = vgallery_detect_mobile();
     /** Embed player code */
     if (isset($fetched) && $fetched[0]->file_type == 5 && !empty($fetched[0]->embedcode)) {
         $playerembedcode = stripslashes($fetched[0]->embedcode);
         $playeriframewidth = str_replace('width=', 'width="' . $width . '"', $playerembedcode);
         if ($mobile) {
             $output .= $playerembedcode;
         } else {
             $output .= str_replace('height=', 'height="' . $height . '"', $playeriframewidth);
             watchedVideoHitCount($fetched[0]->vid, false);
         }
     } else {
         if ($mobile) {
             /** Check mobile device is detected */
             /** Get video detail for HTML5 player
              * Load video details */
             foreach ($fetched as $media) {
                 $videourl = $media->file;
                 $file_type = $media->file_type;
                 $imgurl = getImagesValue($media->image, $file_type, $media->amazon_buckets, '');
             }
             /** Check file type youtube, viddler,dailymotion */
             if ($file_type == 3 || $file_type == 1) {
                 if (strpos($videourl, 'youtube') > 0) {
                     $videoid = getYoutubeVideoID($videourl);
                     $output = '<div id="player"></div><script>var tag = document.createElement("script");tag.src = "https://www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName("script")[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() {player = new YT.Player("player", {width: "100%",videoId: "' . $videoid . '",playerVars: {"rel": 0,"showinfo":0,"modestbranding":0},events: {"onStateChange": onPlayerStateChange}});}var done = false;function onPlayerStateChange(event) {if (event.data == YT.PlayerState.PLAYING && !done) {currentVideoP(' . $videoId . ');done = true;}}</script>';
                     echo $output;
                     /** Generate youtube embed code for html5 player */
                 } else {
                     if (strpos($videourl, 'viddler') > 0) {
                         /** For viddler videos in URL method */
                         $imgstr = explode('/', $videourl);
                         $viddler_id = $imgstr[4];
                         $output = '<script type="text/javascript" src="//static.cdn-ec.viddler.com/js/arpeggio/v3/build/main-built.js"></script><div id="my-player"></div><script>var embed = new ViddlerEmbed({videoId: "' . $viddler_id . '",width: "100%",target: "#my-player"});var done = false;embed.manager.events.on("videoPlayer:play", function() {if (!done) {currentVideoP(' . $videoId . ');done = true;}});</script>';
                     } elseif (strpos($videourl, 'dailymotion') > 0) {
                         /** For dailymotion videos in URL method */
                         $split_id = getDailymotionVideoID($videourl);
                         $video = $videourl = $this->_protocolURL . 'www.dailymotion.com/embed/video/' . $split_id[0];
                         $output = '<script src="http://api.dmcdn.net/all.js"></script><div id="player"></div><script>var player = DM.player(document.getElementById("player"),{video: "' . $split_id[0] . '",width: "100%",params: {html: 0,wmode: "opaque"},events: {playing: function(){onPlayerStateChange();}}});var done = false;function onPlayerStateChange(){if (!done) {currentVideoP(' . $videoId . ');done = true;}}</script>';
                         echo $output;
                     } else {
                         $output .= '<video width="100%" height="' . $height . '" id="video" poster="' . $imgurl . '"   src="' . $videourl . '" autobuffer controls onerror="failed( event )">' . $htmlplayer_not_support . '</video>';
                     }
                 }
             } else {
                 /** For uploaded videos, get video URL */
                 $video_url = getVideosValue($videoFile, $file_type, $amazonBucket);
                 /** Check for RTMP videos */
                 if ($file_type == 4) {
                     $streamer = str_replace('rtmp://', 'http://', $media->streamer_path);
                     $video_url = $streamer . '_definst_/mp4:' . $videourl . '/playlist.m3u8';
                 }
                 /** Generate video code for html5 player */
                 $output .= '<video width="100%" height="' . $height . '" id="video" poster="' . $imgurl . '"   src="' . $video_url . '" autobuffer controls onerror="failed( event )">' . $htmlplayer_not_support . '</video>';
             }
         } else {
             $output .= '<div id="flashplayer"><embed src="' . $this->_swfPath . '" flashvars="' . $flashvars . '" width="' . $width . '" height="' . $height . '" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" wmode="transparent"></div>';
             /** Google adsense code Start */
             if ($player_color['googleadsense_visible'] == 1 && !$mobile && ($this->_post_type === APPTHAVIDEOGALLERY || $this->_page_post_type === APPTHAVIDEOGALLERY)) {
                 if ($homeplayerData->google_adsense && $homeplayerData->google_adsense_value) {
                     $output .= '<div>';
                     /**
                      * Call function to dipaly google adsense on player
                      */
                     $output .= $this->displayGoogleAdsense($width, $vid, $homeplayerData->vid);
                 }
             }
         }
     }
     $output .= '</div>';
     /** End Google adsense End. */
     /** Get current user agent */
     $useragent = $_SERVER['HTTP_USER_AGENT'];
     if (strpos($useragent, 'Windows Phone') > 0) {
         /** Check for windows phone */
         $windo = 'Windows Phone';
     }
     /**  Check platform */
     /** Call script to display error message within player */
     $output .= '<script type="text/javascript">
         function current_video_' . $videodivId . '( video_id,d_title ){  
             if( d_title == undefined ) { 
               document.getElementById( "video_title' . $videodivId . '" ).innerHTML=""; 
             } else { 
               document.getElementById( "video_title' . $videodivId . '" ).innerHTML=""; 
               document.getElementById( "video_title' . $videodivId . '" ).innerHTML=d_title; 
             } 
         } var txt =  navigator.platform ; 
         var windo = "' . $windo . '"; 
         function failed( e ) { 
             if( txt =="iPod"|| txt =="iPad" || txt == "iPhone" || windo=="Windows Phone" || txt == "Linux armv7l" || txt == "Linux armv6l" ) { 
               alert( "' . $player_not_support . '" ); 
             } 
         } </script>';
     /** Player ends here
      * Display description, views, tags, playlist names detail under player */
     if (isset($arguments['views']) && $arguments['views'] == 'on') {
         $videogalleryviews = true;
     } else {
         if (($this->_post_type === APPTHAVIDEOGALLERY || $this->_page_post_type === APPTHAVIDEOGALLERY) && $configXML->view_visible == 1) {
             $videogalleryviews = true;
         } else {
             $videogalleryviews = false;
             $no_views = 'noviews';
         }
     }
     /** Call function to display view count, posted on details in video detail page   */
     $output .= $this->displayViewsPostedON($show_added_on, $videogalleryviews, $no_views, $post_date, $hitcount);
     /** Display user name under player */
     $output .= '<div class="clearfix"></div>';
     if ($this->_post_type === APPTHAVIDEOGALLERY || $this->_page_post_type === APPTHAVIDEOGALLERY) {
         $user_url = get_user_permalink($this->_mPageid, $uploadedby_id, $uploadedby);
         if ($show_posted_by) {
             $output .= '<div class="video-page-username"><strong>' . __('Posted&nbsp;by', APPTHA_VGALLERY) . '&nbsp;:&nbsp;</strong><a href="' . $user_url . '">' . $uploadedby . '</a></div>';
         }
         /** Display category name under player  */
         if ($configXML->categorydisplay == 1) {
             /** Category display function */
             $output .= $this->displayCategory($vid);
         }
     }
     /**  Rating starts here for video details page  */
     if ($this->_post_type === APPTHAVIDEOGALLERY || $this->_page_post_type === APPTHAVIDEOGALLERY) {
         /** Set ratings control if enabled for player */
         if ($configXML->ratingscontrol == 1) {
             $ratingscontrol = true;
         } else {
             $ratingscontrol = false;
         }
     } else {
         if (isset($arguments['ratingscontrol']) && $arguments['ratingscontrol'] == 'on') {
             $ratingscontrol = true;
         } else {
             $ratingscontrol = false;
         }
     }
     /** Show ratings star avg */
     if ($ratingscontrol) {
         $ratestar = getRatingValue($rate, $ratecount, 'calc');
         /** Display ratings under player */
         $output .= $this->displayRatings($ratestar, $ratecount, $videodivId, $vid, $videoId);
     }
     /** Rating ends here */
     $output .= '</div>';
     if ($this->_post_type === APPTHAVIDEOGALLERY || $this->_page_post_type === APPTHAVIDEOGALLERY) {
         /** Display tag info */
         if (!empty($tag_name) && $configXML->tagdisplay == 1) {
             $output .= '<div class="video-page-tag"><strong>' . __('Tags', APPTHA_VGALLERY) . '          </strong>: ' . $tag_name . ' ' . '</div>';
         }
         /** Check if video url is YouTube */
         if (strpos($videoUrl, 'youtube') > 0) {
             $video_thumb = $this->_protocolURL . 'img.youtube.com/vi/' . getYoutubeVideoID($videoUrl) . '/hqdefault.jpg';
         }
         /** Display description */
         if (!empty($description)) {
             $removequotedescription = str_replace('"', '', $description);
             $videodescription = str_replace("'", '', $removequotedescription);
         } else {
             $videodescription = get_bloginfo('name');
         }
         /** Check amazon s3 bucket is enabled */
         if ($fetched[0]->amazon_buckets == 1) {
             $video_thumb = '';
         }
         /** Load rss url link */
         $rs_url = $this->_site_url . '/wp-admin/admin-ajax.php?action=rss&type=video&vid=' . $vid;
         $rss_image = getImagesDirURL() . '/rss_icon.png';
         /** Show social icons below player */
         if ($show_social_icon) {
             /** Function to display social icons
              * and rss icon */
             $output .= $this->displaySocialIcons($configXML->keyApps, $videodescription, $video_thumb, $video_title);
             /** Show rss url link and image
              * Build rss icon div */
             if ($show_rss_icon) {
                 $output .= '<div class="floatleft rssfeed">&nbsp;&nbsp;<a href="' . $rs_url . '"><img src="' . $rss_image . '"></a></div>';
             }
             $output .= '</div>';
             $output .= '<div class="clearfix">';
         }
         $output .= '<div class="video-cat-thumb">';
         /** Show rss icon enable / disable  */
         if ($show_rss_icon && !$show_social_icon) {
             $rs_url = $this->_site_url . '/wp-admin/admin-ajax.php?action=rss&type=video&vid=' . $vid;
             $rss_image = getImagesDirURL() . '/rss_icon.png';
             $output .= '<div class="video-socialshare"><div class="floatleft rssfeed">&nbsp;&nbsp;<a href="' . $rs_url . '"><img src="' . $rss_image . '"></a></div></div>';
         }
         /** Show or hide embed /iframe/report video option code for video detail page..  */
         if ($configXML->embed_visible == 1) {
             $output .= '<a href="javascript:void( 0 )" onclick="enableEmbed();" class="embed" id="allowEmbed"><span class="embed_text">' . __('Embed&nbsp;Code', APPTHA_VGALLERY) . '</span><span class="embed_arrow"></span></a>';
         }
         if (isset($player_color['iframe_visible']) && $player_color['iframe_visible']) {
             $output .= '<a href="javascript::void(0);" onclick="view_iframe_code();" id="iframe_code" class="embed"><span class="embed_text">' . __('Iframe', APPTHA_VGALLERY) . '</span><span class="embed_arrow"></span></a>';
         }
         if (isset($player_color['report_visible']) && $player_color['report_visible']) {
             $output .= '<a href="javascript:void(0)" onclick="reportVideo();" class="embed" id="allowReport"><span class="embed_text">' . __('Report&nbsp;Video', APPTHA_VGALLERY) . '</span><span class="embed_arrow"></span></a>';
         }
         /** Condition for embed code */
         if ($fetched[0]->file_type == 5 && !empty($fetched[0]->embedcode)) {
             $embed_code = stripslashes($fetched[0]->embedcode);
         } else {
             /** Display embed code */
             $embed_code = '<embed src="' . $this->_swfPath . '" flashvars="' . $flashvars . '&amp;shareIcon=false&amp;email=false&amp;showPlaylist=false&amp;zoomIcon=false&amp;copylink=' . get_permalink() . '&amp;embedplayer=true" width="' . $width . '" height="' . $height . '" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" wmode="transparent">';
         }
         /** Call fucntion to display report video option */
         $output .= $this->displayReportVideo($embed_code, $video_slug, $current_user->user_email);
         /** Load embed code */
         if ($fetched[0]->file_type == 5 && $fetched[0]->embedcode) {
             $iframe_code = stripslashes($fetched[0]->embedcode);
         } else {
             /** Load iframe code */
             $iframe_code = '<iframe src="' . $this->_swfPath . '?' . $flashvars . '&amp;shareIcon=false&amp;email=false&amp;showPlaylist=false&amp;zoomIcon=false&amp;copylink=' . get_permalink() . '&amp;embedplayer=true" frameborder="0" width="' . $width . '" height="' . $height . '" ></iframe>';
         }
         $output .= '<textarea row="7" col="60" id="iframe-content" name="iframe-content" style="display:none;" onclick="this.select();">' . $iframe_code . '</textarea><input type="hidden" value="" id="iframeflag" name="iframeflag" />';
         /** Show /hide video description. */
         if ($configXML->showTag) {
             $output .= '<div style="clear: both;"></div><div class="video-page-desc">' . apply_filters('the_content', $description) . '</div>';
         }
         $output .= '</div></div>';
     }
     $output .= '</div></div>';
     /** Enable/disable Related videos slider */
     $flag = 0;
     if ($vid && isset($arguments['playlistid']) && isset($arguments['relatedvideos']) && $arguments['relatedvideos'] == 'on') {
         $flag = 1;
     }
     if ($flag == 1 || ($this->_post_type === APPTHAVIDEOGALLERY || $this->_page_post_type === APPTHAVIDEOGALLERY) && $player_color['show_related_video'] == 1) {
         /** Call function to display related videos slider */
         $output .= $this->relatedVideoSlider($vid, $video_playlist_id, $pluginflashvars, $width, $height, $videodivId);
     }
     /** To display video comments section */
     return $output . $this->videoComments($configXML);
 }
 /** Function for adding video and update status / featured. */
 public function add_newvideo()
 {
     /** Variable declaration and initialization */
     $match = '';
     /** Assign youtube URL without id */
     $youtubeVideoURL = 'http://www.youtube.com/watch?v=';
     /** Check video status is exists  */
     if (isset($this->_status) || isset($this->_featured)) {
         /** Call function to update video status */
         $this->status_update($this->_videoId, $this->_status, $this->_featured);
     }
     /** Check whether to add / update video */
     if ($this->_addnewVideo) {
         /** Get video name parameters from the request */
         $videoName = filter_input(INPUT_POST, 'name');
         /** Get video description parameters from the request */
         $videoDescription = filter_input(INPUT_POST, 'description');
         /** Get embed_code parameters from the request */
         $embedcode = filter_input(INPUT_POST, 'embed_code');
         /** Get publish parameters from the request */
         $videoPublish = filter_input(INPUT_POST, 'publish');
         /** Get feature parameters from the request */
         $videoFeatured = filter_input(INPUT_POST, 'feature');
         /** Get download parameters from the request */
         $videoDownload = filter_input(INPUT_POST, 'download');
         /** Get midrollads parameters from the request */
         $videomidrollads = filter_input(INPUT_POST, 'midrollads');
         /** Get imaad parameters from the request */
         $videoimaad = filter_input(INPUT_POST, 'imaad');
         /** Get postrollads parameters from the request */
         $videoPostrollads = filter_input(INPUT_POST, 'postrollads');
         /** Get prerollads parameters from the request */
         $videoPrerollads = filter_input(INPUT_POST, 'prerollads');
         /** Get googleadsense parameters from the request */
         $google_adsense = filter_input(INPUT_POST, 'googleadsense');
         /** Get google_adsense_value parameters from the request */
         $google_adsense_value = filter_input(INPUT_POST, 'google_adsense_value');
         /**
          * Get member id from request.
          * If not get current user id
          */
         $member_id = filter_input(INPUT_POST, 'member_id');
         if (empty($member_id)) {
             $current_user = wp_get_current_user();
             $member_id = $current_user->ID;
         }
         /** Get upload video form params */
         $video1 = filter_input(INPUT_POST, 'normalvideoform-value');
         /** Get upload hd video form params */
         $video2 = filter_input(INPUT_POST, 'hdvideoform-value');
         /** Get thumb image form params */
         $img1 = filter_input(INPUT_POST, 'thumbimageform-value');
         /** Get preview image form params */
         $img2 = filter_input(INPUT_POST, 'previewimageform-value');
         /**  Get streamer path option for rtmp streaming */
         $islive = filter_input(INPUT_POST, 'islive-value');
         /**  Get is live option for rtmp streaming */
         $streamname = filter_input(INPUT_POST, 'streamerpath-value');
         /** Get Youtube video url from request */
         $videoLinkurl = filter_input(INPUT_POST, 'youtube-value');
         /** Set video duration */
         $duration = '0:00';
         /** Get video added method */
         $video_added_method = filter_input(INPUT_POST, 'filetypevalue');
         /** Get amazon bucket params */
         $amazon_buckets = filter_input(INPUT_POST, 'amazon_buckets');
         /** Check youtbe / youtu.be / dailymotion / viddler video url is exists */
         if ($videoLinkurl != '') {
             /** Attach http with video url */
             if (preg_match('#https?://#', $videoLinkurl) === 0) {
                 $videoLinkurl = 'http://' . $videoLinkurl;
             }
             /** Remove spaces in video url */
             $act_filepath = addslashes(trim($videoLinkurl));
         }
         if ($videoLinkurl != '' && $act_filepath != '') {
             /** Set file type 1 for YouTube/ viddler /dailymotion  */
             $file_type = '1';
             /** Check video url contains youtbe / youtu.be / dailymotion / viddler */
             if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
                 /** Get youtube video id from plugin helper */
                 $youtubeVideoID = getYoutubeVideoID($act_filepath);
                 /** Get thumb URL for YouTube videos */
                 $act_opimage = $previewurl = 'http://img.youtube.com/vi/' . $youtubeVideoID . '/maxresdefault.jpg';
                 /** Get preview URL for YouTube videos */
                 $act_image = $img = 'http://img.youtube.com/vi/' . $youtubeVideoID . '/mqdefault.jpg';
                 /** Get YouTube video URL and fetch information  */
                 $act_filepath = $youtubeVideoURL . $youtubeVideoID;
                 $ydetails = hd_getsingleyoutubevideo($youtubeVideoID);
                 /** Get youTube video duration */
                 $youtube_time = $ydetails['items'][0]->contentDetails->duration;
                 if (!empty($youtube_time)) {
                     /** Convert duration into h:m:s format */
                     $di = new DateInterval($youtube_time);
                     $string = '';
                     $min = $di->i;
                     if ($di->h > 0) {
                         $string .= $di->h . ':';
                         /** Check if minutes is <= 9 while hours value is exist */
                         if ($min <= 9) {
                             $min = '0' . $min;
                         }
                     }
                     $duration = $string . $min . ':' . $di->s;
                 }
             } else {
                 if (strpos($act_filepath, 'dailymotion') > 0) {
                     /** Check video URL is dailymotion
                      * If yes, then get id from the url and get thumb, preview image */
                     $split_id = getDailymotionVideoID($act_filepath);
                     $img = $act_image = $act_opimage = $previewurl = 'http://www.dailymotion.com/thumbnail/video/' . $split_id[0];
                 } else {
                     if (strpos($act_filepath, 'viddler') > 0) {
                         /** Check video url is viddler
                          * If yes, then get id from the url and get thumb, preview image */
                         $imgstr = explode('/', $act_filepath);
                         $img = $act_image = $act_opimage = $previewurl = 'http://cdn-thumbs.viddler.com/thumbnail_2_' . $imgstr[4] . '_v1.jpg';
                     } else {
                         $img = '';
                     }
                 }
             }
         } else {
             /** Get video upload form value */
             $act_filepath1 = $_REQUEST['normalvideoform-value'];
             /** Combine upload directory path and file name */
             $act_filepath1 = $this->_srt_path . $act_filepath1;
             /**
              * Check whether custom url option is used
              * If yes, then get video url, thumb url and remove spaces
              * Else, set video url, thumb url as empty
              */
             $act_filepath = $act_optimage = '';
             if (isset($_POST['custom_url'])) {
                 $act_filepath = addslashes(trim($_POST['customurl']));
                 $act_optimage = addslashes(trim('thumb_' . $_POST['custom_url']));
             }
             /** Get ffmpeg settings value */
             $ffmpeg_path = $this->_settingsData->ffmpeg_path;
             /** Set file type as 2 for upload method */
             $file_type = '2';
             /** Get uploaded video duration from plugin helper using ffmpeg */
             $ffmpegResult = getVideoDuration($ffmpeg_path, $act_filepath1);
             $duration = $ffmpegResult[0];
             $matches = $ffmpegResult[1];
             if (!empty($duration)) {
                 /** Convert duration into hours:minutes format */
                 $duration_array = explode(':', $matches[1][0]);
                 $sec = ceil($duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2]);
                 $duration = $this->converttime($sec);
             }
         }
         /** If upload new image for existing video, then rename the images name */
         if ($this->_videoId) {
             $newImagePath = $this->_srt_path . $img1;
             $newPreviewImagePath = $this->_srt_path . $img2;
             $newThumbFileName = explode('_', $img1);
             $newPreviewThumbFileName = explode('_', $img2);
             /**
              * Check if added method is upload
              */
             if ($video_added_method == 2) {
                 /**
                  * Check thumb image is exst in the directory
                  * If exit then rename the new thumb image with the video id
                  */
                 if (file_exists($newImagePath)) {
                     $img1 = $this->_videoId . '_' . $newThumbFileName[1];
                     rename($newImagePath, $this->_srt_path . $img1);
                 }
                 if (file_exists($newPreviewImagePath) && !empty($newPreviewThumbFileName[1])) {
                     /**
                      * Check preview image is exst in the directory
                      * If exit then rename the new preview image with the video id
                      */
                     $img2 = $this->_videoId . '_' . $newPreviewThumbFileName[1];
                     rename($newPreviewImagePath, $this->_srt_path . $img2);
                 }
             }
             /**
              * Check if video added method is embed code
              */
             if ($video_added_method == 5) {
                 $newThumbFileName = explode('_', $img1);
                 /**
                  * Check image is exst in the directory
                  * If exit then rename the new image with the video id
                  */
                 if (file_exists($newImagePath)) {
                     $img1 = $img2 = $this->_videoId . '_' . $newThumbFileName[1];
                     rename($newImagePath, $this->_srt_path . $img1);
                 }
             }
         }
         /**
          * Get Amazon S3 bucket settings from database
          */
         $player_colors = getPlayerColorArray();
         /**
          * Check if bucket option is enabled and name is exist
          */
         if ($player_colors['amazonbuckets_enable'] && $player_colors['amazonbuckets_name']) {
             /**
              * Get bucket name
              */
             $s3bucket_name = $player_colors['amazonbuckets_name'];
             /**
              * Check video is exist
              * If exist then get bucket video for uploaded videos
              */
             $video1 = $this->getAmazonURLOrUploadFile($video1, $s3bucket_name);
             /** Get bucket hd video for uploaded videos */
             $video2 = $this->getAmazonURLOrUploadFile($video2, $s3bucket_name);
             /** Get bucket thumb image for uploaded videos */
             $img1 = $this->getAmazonURLOrUploadFile($img1, $s3bucket_name);
             /** Get bucket preview image for uploaded videos */
             $img2 = $this->getAmazonURLOrUploadFile($img2, $s3bucket_name);
         }
         /** Get customurl parameter */
         $act_image = addslashes(trim($_POST['customurl']));
         $act_hdpath = $act_name = $act_opimage = '';
         /** If video url is not empty then get image and preview image */
         if (!empty($act_filepath)) {
             /** Set file type 1 for YouTube, dailymotion and viddler videos */
             $file_type = '1';
             if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
                 /**
                  * Get Youtube video id
                  * Based on that get video URL , image, preview image 
                  */
                 $match = getYoutubeVideoID($act_filepath);
                 $act_filepath = $youtubeVideoURL . $match;
                 /** Get thumbimage for youtube video */
                 $act_image = 'http://i3.ytimg.com/vi/' . $match . '/mqdefault.jpg';
                 /** Get previewimage for youtube video */
                 $act_opimage = 'http://i3.ytimg.com/vi/' . $match . '/maxresdefault.jpg';
                 /** Call fucntion to get YouTube video information */
                 $ydetails = hd_getsingleyoutubevideo($match);
                 if ($ydetails) {
                     if ($act_name == '') {
                         /** Get youtube video title */
                         $act_name = addslashes($ydetails['items'][0]->snippet->title);
                     }
                 } else {
                     /** Else display error for youtube videos*/
                     render_error(__('Could not retrieve Youtube video information', APPTHA_VGALLERY));
                 }
             } else {
                 if (strpos($act_filepath, 'dailymotion') > 0) {
                     /** Get dailymotion video id */
                     $split_id = getDailymotionVideoID($act_filepath);
                     /** Get dailymotion video and thumb url */
                     $act_image = $act_opimage = 'http://www.dailymotion.com/thumbnail/video/' . $split_id[0];
                 } else {
                     if (strpos($act_filepath, 'viddler') > 0) {
                         /** Get viddler video id */
                         $imgstr = explode('/', $act_filepath);
                         /** Get viddler video thumb and preview image */
                         $act_image = $act_opimage = 'http://cdn-thumbs.viddler.com/thumbnail_2_' . $imgstr[4] . '_v1.jpg';
                     } else {
                         $imgstr = '';
                     }
                 }
             }
         } else {
             if ($video1 != '') {
                 $act_filepath = $video1;
             }
             if ($video2 != '') {
                 $act_hdpath = $video2;
             }
             if ($img1 != '') {
                 $act_image = $img1;
             }
             if ($img2 != '') {
                 $act_opimage = $img2;
             }
         }
         /** Set filetype as 5 for embed method */
         if (!empty($embedcode)) {
             $video_added_method = $file_type = '5';
         }
         /** Get video details for URL type videos */
         if ($video_added_method == 3) {
             $act_filepath = $_POST['customurl'];
             $act_image = $_POST['customimage'];
             $act_opimage = $_POST['custompreimage'];
             $act_hdpath = $_POST['customhd'];
         }
         /** Get video details for rtmp videos */
         if (!empty($streamname)) {
             $file_type = '4';
             /** Get filepath3 from params */
             $thumb_image = filter_input(INPUT_POST, 'filepath3');
             $act_image = $thumb_image;
             $act_opimage = $thumb_image;
         }
         if ($video_added_method == 4) {
             /** Get custom url from params */
             $act_filepath = filter_input(INPUT_POST, 'customurl');
             /** Get customhd from params */
             $act_hdpath = filter_input(INPUT_POST, 'customhd');
             /** Get customimage from params */
             $act_image = filter_input(INPUT_POST, 'customimage');
             /** Get custompreimage from params */
             $act_opimage = filter_input(INPUT_POST, 'custompreimage');
         }
         /** Store video form values into single array */
         $videoData = array('name' => $videoName, 'description' => $videoDescription, 'embedcode' => $embedcode, 'file' => $act_filepath, 'file_type' => $video_added_method, 'member_id' => $member_id, 'duration' => $duration, 'hdfile' => $act_hdpath, 'streamer_path' => $streamname, 'islive' => $islive, 'image' => $act_image, 'opimage' => $act_opimage, 'link' => $videoLinkurl, 'featured' => $videoFeatured, 'download' => $videoDownload, 'postrollads' => $videoPostrollads, 'midrollads' => $videomidrollads, 'imaad' => $videoimaad, 'prerollads' => $videoPrerollads, 'publish' => $videoPublish, 'google_adsense' => $google_adsense, 'google_adsense_value' => $google_adsense_value, 'amazon_buckets' => $amazon_buckets);
         /**
          * Get current date and assign default value
          * for srt files, language and slug
          */
         //$videoData ['post_date']  = date ( 'Y-m-d H:i:s' );
         if (empty($this->_videoId)) {
             $videoData['ordering'] = getAllVideosCount();
             $videoData['slug'] = $videoData['srtfile1'] = $videoData['srtfile2'] = $videoData['subtitle_lang1'] = $videoData['subtitle_lang2'] = '';
         }
         /** Call funtion to perform add / update action */
         $this->addUpdateVideoData($videoData);
     }
 }
Esempio n. 3
0
</a></div>
				<div class="row">
					<?php 
    while ($pageVideos->have_posts()) {
        $pageVideos->the_post();
        ?>
						<?php 
        $videosURLs = get_field('repeater_video');
        $count = 0;
        if ($videosURLs) {
            foreach ($videosURLs as $entry) {
                if ($count < $limitVideo) {
                    ?>
									<div class="col-md-4 col-sm-6 entry-inline">
										<iframe class="media-video" src="https://www.youtube.com/embed/<?php 
                    echo getYoutubeVideoID($entry['video_url']);
                    ?>
" frameborder="0" allowfullscreen></iframe>
									</div>
									<?php 
                    $count++;
                    ?>
								<?php 
                }
                ?>
							<?php 
            }
            ?>
						<?php 
        }
        ?>
Esempio n. 4
0
 /**
  * Show video players
  */
 function home_player()
 {
     /** Varaiable Initialization for home page display */
     $videoUrl = $videoId = $thumb_image = $homeplayerData = $file_type = $baseref = $showplaylist = $windo = '';
     /** Get settings data from constructor */
     $settingsData = $this->_settingsData;
     /** Get featured videos for home page player */
     if (!empty($this->_featuredvideodata[0])) {
         $homeplayerData = $this->_featuredvideodata[0];
     }
     if (!empty($homeplayerData)) {
         /** Get home page player video details  */
         $videoId = $homeplayerData->vid;
         $videoUrl = $homeplayerData->file;
         $file_type = $homeplayerData->file_type;
         $video_title = $homeplayerData->name;
         $thumb_image = getImagesValue($homeplayerData->image, $file_type, $homeplayerData->amazon_buckets, '');
     }
     /** Call query helper to detect mobile or browser */
     $mobile = vgallery_detect_mobile();
     /** Home Page Player starts */
     $div = '<div> <style type="text/css" scoped> .video-block {margin-left:' . $settingsData->gutterspace . 'px !important; float:left;} </style>';
     $div .= ' <script> var baseurl = "' . $this->_site_url . '"; </script>';
     $baseref .= '&amp;featured=true';
     if (!empty($this->_vId)) {
         $baseref .= '&amp;vid=' . $this->_vId;
     }
     /** Show / hide the video title of the home page players */
     $div .= '<div id="mediaspace" class="mediaspace" style="color: #666;">';
     if (isset($this->_player_colors['showTitle']) && $this->_player_colors['showTitle']) {
         $div .= '<script type="text/javascript">function current_video( vid, title ){ document.getElementById("video_title").innerHTML = title; }</script>';
         $div .= '<h3 id="video_title" style="width:' . $settingsData->width . ';text-align: left;"  class="more_title">';
         /** Display for video title in mobile */
         if ($mobile) {
             $div .= $video_title;
         }
         $div .= '</h3>';
     }
     $div .= '<div id="flashplayer" class="videoplayer">';
     /**
      * Check player is enabled
      * If yes then assgin plugin player path 
      * Else assign banner player path 
      */
     $swf = $this->_swfPath;
     if ($settingsData->default_player == 1) {
         $swf = $this->_bannerswfPath;
         $showplaylist = '&amp;showPlaylist=true';
     }
     /** Check embed code method or not  */
     if ($file_type == 5 && !empty($homeplayerData->embedcode)) {
         $div .= str_replace('width=', 'width="' . $settingsData->width . '"', stripslashes($homeplayerData->embedcode));
         $div .= '<script> current_video( ' . $homeplayerData->vid . ',"' . $homeplayerData->name . '" ); </script>';
     } else {
         /** Check mobile device is detect */
         if ($mobile) {
             if (preg_match('/vimeo/', $videoUrl) && $videoUrl != '') {
                 /** Iframe code for vimeo videos */
                 $vresult = explode('/', $videoUrl);
                 $div .= '<iframe width="100%" height="' . $settingsData->height . '" type="text/html" src="' . $this->_pluginProtocol . 'player.vimeo.com/video/"' . $vresult[3] . '" frameborder="0"></iframe>';
             } elseif (strpos($videoUrl, 'youtube') > 0) {
                 /** Iframe code for youtube videos */
                 $videoId1 = getYoutubeVideoID($videoUrl);
                 $div = '<div id="player"></div><script>var tag = document.createElement("script");tag.src = "https://www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName("script")[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() {player = new YT.Player("player", {width: "100%",videoId: "' . $videoId1 . '",playerVars: {"rel": 0,"showinfo":0,"modestbranding":0},events: {"onStateChange": onPlayerStateChange}});}var done = false;function onPlayerStateChange(event) {if (event.data == YT.PlayerState.PLAYING && !done) {currentVideoP(' . $videoId . ');done = true;}}</script>';
             } elseif (strpos($videoUrl, 'dailymotion') > 0) {
                 /** Iframe code for dailymotion videos */
                 $split_id = getDailymotionVideoID($videoUrl);
                 $video = $this->_pluginProtocol . 'www.dailymotion.com/embed/video/' . $split_id[0];
                 $div = '<script src="http://api.dmcdn.net/all.js"></script><div id="player"></div><script>var player = DM.player(document.getElementById("player"),{video: "' . $split_id[0] . '",width: "100%",params: {html: 0,wmode: "opaque"},events: {playing: function(){onPlayerStateChange();}}});var done = false;function onPlayerStateChange(){if (!done) {currentVideoP(' . $videoId . ');done = true;}}</script>';
             } else {
                 if (strpos($videoUrl, 'viddler') > 0) {
                     /** Iframe code for viddler videos */
                     $imgstr = explode('/', $videoUrl);
                     $div = '<script type="text/javascript" src="//static.cdn-ec.viddler.com/js/arpeggio/v3/build/main-built.js"></script><div id="my-player"></div><script>var embed = new ViddlerEmbed({videoId: "' . $imgstr[4] . '",width: "100%",target: "#my-player"});var done = false;embed.manager.events.on("videoPlayer:play", function() {if (!done) {currentVideoP(' . $videoId . ');done = true;}});</script>';
                 } else {
                     if ($file_type == 4) {
                         $streamer = str_replace('rtmp://', 'http://', $homeplayerData->streamer_path);
                         $videoUrl = $streamer . '_definst_/mp4:' . $videoUrl . '/playlist.m3u8';
                     } else {
                         $videoUrl = getVideosValue($videoUrl, $file_type, $homeplayerData->amazon_buckets);
                     }
                     $div .= '<video width="100%" height="' . $settingsData->height . '" id="video" poster="' . $thumb_image . '"   src="' . $videoUrl . '" autobuffer controls onerror="failed( event )">' . __('Html5 Not support This video Format.', APPTHA_VGALLERY) . '</video>';
                 }
             }
         } else {
             /** If browser is detect then play videos via flash player using embed code */
             $div .= '<embed id="player" src="' . $swf . '"  flashvars="baserefW=' . $this->_siteURL . $baseref . $showplaylist . '&amp;mtype=playerModule" width="' . $settingsData->width . '" height="' . $settingsData->height . '"   allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" wmode="transparent" />';
         }
     }
     $div .= '</div>';
     /** Get user agent */
     $useragent = $_SERVER['HTTP_USER_AGENT'];
     if (strpos($useragent, 'Windows Phone') > 0) {
         $windo = 'Windows Phone';
     }
     /** Section to notify not support video format */
     $div .= '<script>  var txt =  navigator.platform ;  var windo = "' . $windo . '";  function failed( e ) { if( txt =="iPod"|| txt =="iPad" || txt == "iPhone" || windo=="Windows Phone" || txt == "Linux armv7l" || txt == "Linux armv6l" ) { alert( "' . __('Player doesnot support this video.', APPTHA_VGALLERY) . '" ); } } </script>';
     $div .= '<div id="video_tag" class="views"></div> </div>';
     return $div . '</div>';
 }