public function init() { $assets = dirname(__FILE__) . '/assets'; $this->assetsPath = Yii::app()->assetManager->publish($assets, false, 1, YII_DEBUG); if (empty($this->imageAds)) { $this->imageAds = '/web/images/bg_default.png'; } if (empty($this->data)) { $data[] = array('file' => 'https://s3.amazonaws.com/jomedia-jwplayer/samples/tears-of-steel.mp4', 'label' => '128K'); $data[] = array('file' => 'https://s3.amazonaws.com/jomedia-jwplayer/samples/tears-of-steel.mp4', 'label' => '320K VIP'); $source = json_encode($data); } $video = VideoModel::model()->findByPk($this->videoId); //check xem co phai iphone 3G khong $device = Yii::app()->session['device']; /*if(!empty($device) && $device['os'] == 'iOS' && (int) Yii::app()->session['deviceOS'] <= 6 ){ $source = VideoModel::model()->builDataPlayerVideo($this->videoId,null, Yii::app()->params['video.profile.default']['iphone'][0]); }else { $source = VideoModel::model()->builDataPlayerVideo($this->videoId); }*/ $source = VideoModel::model()->builDataPlayerVideo($this->videoId); $image = AvatarHelper::getAvatar("video", $this->videoId, 640); $cs = Yii::app()->clientScript; $cs->registerScriptFile($this->assetsPath . '/jwplayer.js', CClientScript::POS_END); $cs->registerScript('play_video' . $this->id, "\n jwplayer('" . $this->id . "').setup({\n width: '" . $this->width . "',\n height: " . $this->height . ",\n image: '" . $image . "',\n sources: {$source},\n autostart: " . $this->autostart . ",\n expand: '" . $this->expand . "',\n primary: '" . $this->primary . "',\n /*plugins: {\n '" . $this->assetsPath . "/vast.js': {\n client:'vast',\n schedule:{\n overlay: { offset: " . $this->offset . ", tag: '" . Yii::app()->createUrl('/player/banner') . "', type:'nonlinear' }\n }\n }\n }*/\n });\n ", CClientScript::POS_END); if ($this->expand) { $cs->registerScript('play_video_expand' . $this->id, "\n function onPlayerExpandCollapse() {\n\n if(jwplayer('" . $this->id . "').getFullscreen) {\n jwplayer('" . $this->id . "').setFullscreen(false);\n }\n if(\$('.video_player').width() <= 745){\n \$('.colum2').css({'margin-top':'20px'});\n \$('.video_player').css({'height':'540px'});\n \$('.video_player').css({'width':'960px'});\n \$('#player-holder').removeClass('watch-normal-mode');\n \$('#player-holder').addClass('watch-large-mode');\n \$('.video_player .colum2').css({'margin-top':'-370px'});\n onPlayerExpand();\n }else{\n onPlayerCollapse();\n \$('.colum2').css({'margin-top':''});\n \$('.video_player').css({'height':'390px'});\n \$('.video_player').css({'width':'745px'});\n \$('#player-holder').removeClass('watch-large-mode');\n \$('#player-holder').addClass('watch-normal-mode');\n }\n }\n\n function onPlayerExpand() {\n jwplayer('" . $this->id . "').resize(960,540);\n }\n\n function onPlayerCollapse() {\n jwplayer('" . $this->id . "').resize(745,390);\n }\n ;\n ", CClientScript::POS_END); } //track and log $deviceType = 'mobile'; $isUserLogin = Yii::app()->user->isGuest ? 'false' : 'true'; $cs->registerScript('play_video_current' . $this->id, "\n var device_type = '" . $deviceType . "';\n var listPlayed =Array();\n var playVideoFlag = true;\n var logedin = " . $isUserLogin . ";\n jwplayer().onPlay(function(){\n console.log(JSON.stringify(check_video_quality()));\n if(!check_video_quality()){\n jwplayer('" . $this->id . "').pause();\n }\n\n });\n jwplayer().onBeforePlay(function() {\n\n playVideoFlag = false;\n });\n jwplayer().onTime(function(event) {\n if(Math.round(event.position) >=5){\n if(playVideoFlag) {\n playVideoFlag = false;\n var action = 'Play Video';\n if(in_array_item(listPlayed,'video_" . $video->id . "')){\n var action = 'Replay Video';\n }\n var item = 'video_" . $video->id . "';\n if(!in_array_item(listPlayed,item)){\n listPlayed.push(item);\n }\n console.log(device_type+'-'+action);\n ga('send', 'event', device_type, action,'" . CHtml::encode($video->name . "-" . $video->artist_name . "-" . $video->id) . "');\n ajax_load('/player/logVideo',{'id':" . $video->id . "});\n }\n }\n });\n ", CClientScript::POS_END); //check login 720p $obj = array("obj_type" => 'video', 'name' => $video->name, 'id' => $video->id, 'artist' => $video->artist_name); $urlDetail = URLHelper::makeUrl($obj); $lac = Yii::app()->user->getState('last_action'); $lurl = Yii::app()->user->getState('last_url'); Yii::app()->user->setState('last_url', null); $register_url = Yii::app()->createUrl("account/package"); $login_url = Yii::app()->createUrl("account/login"); $js = ''; if ($lac == '720p' && $lurl == $urlDetail && !Yii::app()->user->isGuest) { $js = 'jwplayer().setCurrentQuality(0);'; } $js = 'jwplayer().setCurrentQuality(0);'; $cs->registerScript('play_video_current_changeQ' . $this->id, "\n\n jwplayer().onQualityLevels(function(event){\n var currQIndex = jwplayer().getCurrentQuality();\n var currQL = jwplayer().getQualityLevels();\n var bitrate = currQL[currQIndex].label;\n if(logedin==false && bitrate=='720p'){\n jwplayer().setCurrentQuality(currQIndex+1);\n }\n jwplayer().setCurrentQuality(currQIndex+1);\n });\n jwplayer().onQualityChange(function(event){\n var logedin = false;\n\n \$.ajax({\n url: '/ajax/isAuthenticate',\n type: 'post',\n data: {fa:'720p',url_return:'" . $urlDetail . "'},\n async: false,\n dataType: 'json',\n success: function(data){\n if(data.errorCode==0){\n logedin = true;\n }\n }\n })\n var currEQIndex = jwplayer().getCurrentQuality();\n var currQL = jwplayer().getQualityLevels();\n var bitrate = currQL[currEQIndex].label;\n\n if(logedin==false && bitrate=='720p'){\n var html = 'Quý khách vui lòng đăng ký để nghe miễn phí nội dung chất lượng cao.';\n html += '<div class=\"clb ovh\">';\n html += '<div class=\"btn-popup btn-popup-green\" style=\"width: 45%; float: left;\">';\n html += '<a href=\" {$register_url} \" class=\"show\" style=\"color: #FFF\">Đăng ký</a>';\n html += '</div>';\n html += '<div class=\"btn-popup btn-popup-green\" style=\"width: 45%; float: right;\">';\n html += '<a href=\"javascript::void();\" onclick=\"Popup.close()\" class=\"show\" style=\"color: #FFF\">Hủy</a>';\n html += '</div>';\n html += '</div>';\n html += '</div>';\n Popup.alert(html);\n\n\n }\n });\n ", CClientScript::POS_END); $cs->registerScript('check_current_video' . $this->id, "\n function check_video_quality(){\n var anable_play = true;\n var currEQIndex = jwplayer().getCurrentQuality();\n var currQL = jwplayer().getQualityLevels();\n var bitrate = currQL[currEQIndex].label;\n if(!userSubs){\n console.log(JSON.stringify(bitrate));\n if(userPhone && bitrate == '720p'){\n return false;\n }else{\n }\n }\n }\n ", CClientScript::POS_END); parent::init(); }
<div id="shuffle" style="display: none;">Shuffle</div> </div> <div class="clear"></div> <div class="box_content"> <ul id="playlist" class="<?php echo $this->classScroll; ?> list_song album_song_list"> <?php $songs = $this->songs; $i = 0; if ($songs) { Yii::app()->SEO->addMetaProp('music:song_count', count($songs)); foreach ($songs as $song) { $obj = array("obj_type" => 'song', 'name' => $song->name, 'id' => $song->id, 'artist' => $song->artist_name); $link = URLHelper::makeUrl($obj); Yii::app()->SEO->addMetaProp('music:song', $link); Yii::app()->SEO->addMetaProp('music:song:track', $i + 1); $duration = isset($song->duration) ? $song->duration : 250; $songName = CHtml::encode($song->name); $artistLink = Yii::app()->createUrl("/search") . "?" . http_build_query(array("q" => CHtml::encode($song->artist_name))); $urlKey = !empty($song->url_key) ? $song->url_key : Common::makeFriendlyUrl($song->name); $shareLink = $link; ?> <li class="item item-in-list song-item-<?php echo $i; ?> " id="song_<?php echo $song->id; ?> "