public function actionView() { $radioId = Yii::app()->request->getParam("id", 0); $radioName = WapRadioModel::model()->findByPk($radioId)->name; $albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id"); $radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1'); $album = WapAlbumModel::model()->published()->findByPk($albumId); if (!$album) { $this->forward("/site/error", true); } $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId); $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId); $phone = yii::app()->user->getState('msisdn'); $errorCode = 'success'; $errorDescription = ''; $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT'); ///meta tag $AlbumDetail = AlbumModel::model()->findByPk($albumId); $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id; $ArtistInfo = ArtistModel::model()->findByPk($artistId); $this->itemName = $AlbumDetail->name; $this->artist = $ArtistInfo->name; $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1'); $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name)); $this->description = strip_tags($AlbumDetail->description); //get other radio $parent_id = Yii::app()->params['horoscope']['parent_id']; $radioListOther = WapRadioModel::model()->getHoroscopes($parent_id); $this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar)); }
public function actionView() { $id = Yii::app()->request->getParam('id', 0); $topContent = TopContentModel::model()->findByPk($id); if (!$topContent) { $this->forward("/site/error", true); } if ($topContent->type == 'album') { $content = AlbumModel::model()->findByPk($topContent->content_id); } elseif ($topContent->type == 'video_playlist') { $content = WapVideoPlaylistModel::model()->published()->with('video_playlist_artist')->findByPk($topContent->content_id); } if (!$content || $content->status != 1) { $this->forward("/site/error", true); } $this->render('view', compact('topContent', 'content')); }
public function init() { $assets = dirname(__FILE__) . '/assets'; $this->assetsPath = Yii::app()->assetManager->publish($assets, false, 1, YII_DEBUG); $cs = Yii::app()->clientScript; $cs->registerCssFile($this->assetsPath . '/css/stylejwp.css'); $cs->registerScriptFile($this->assetsPath . '/jwplayer.js'); $album = AlbumModel::model()->findByPk($this->albumId); $this->albumObject = $album; $this->data = AlbumModel::model()->builDataPlayerAlbum($this->albumId, $this->cached); if (!empty($this->data)) { $playlistIndex = AlbumModel::model()->getDataIndexAlbum(); $indexPl = json_decode($this->data); $cs->registerScript('play_album_touch' . $this->id, "\n jwplayer('" . $this->id . "').setup({\n width: '100%',\n height: 35,\n playlist: " . $this->data . ",\n skin: '" . $this->assetsPath . "/vega-skin-album-min-2.xml',\n autostart: '" . $this->autostart . "',\n primary: '" . $this->primary . "'\n });", CClientScript::POS_END); $cs->registerScript('play_album_touch_option' . $this->id, "\n jwplayer().onReady(function() {\n var state = jwplayer().getState();\n if(state=='IDLE'){\n \$('#play').show();\n \$('#pause').hide();\n }\n jwplayer().setVolume(100);\n });\n var isShuffle = false;\n var currentId = 0;\n jwplayer().onPlaylistItem(function() {\n //logSongFlag = true;\n var currentItem = jwplayer().getPlaylistItem();\n currentId = currentItem['mediaid'];\n //\$('#vg-player li').removeClass('active');\n //\$('#vg-player-item-'+currentItem['mediaid']).addClass('active');\n \$('#item-title').html(currentItem['title']);\n });\n\n jwplayer().onPlay(function(){\n var state = jwplayer().getState();\n if(state=='PLAYING'){\n \$('#play').hide();\n \$('#pause').show();\n }else{\n \$('#play').show();\n \$('#pause').hide();\n\n }\n });\n\n \$('#play').click(function(){\n jwplayer().play();\n \$('#play').hide();\n \$('#pause').show();\n });\n\n \$('#pause').click(function(){\n jwplayer().pause();\n \$('#play').show();\n \$('#pause').hide();\n });\n\n \$('#next').click(function(){\n var state = jwplayer().getState();\n var curentIndex = jwplayer().getPlaylistIndex();\n var totalItem = jwplayer().getPlaylist().length;\n if(curentIndex<totalItem){\n nextItem = curentIndex+1;\n }else{\n nextItem = 0;\n }\n if(isShuffle){\n nextItem = randomItem();\n }\n jwplayer().playlistItem(nextItem);\n\n return false;\n })\n\n \$('#prev').click(function(){\n var state = jwplayer().getState();\n var curentIndex = jwplayer().getPlaylistIndex();\n var totalItem = jwplayer().getPlaylist().length;\n if(curentIndex <= 0){\n nextItem = totalItem-1;\n }else{\n nextItem = curentIndex-1;\n }\n jwplayer().playlistItem(nextItem);\n return false;\n })\n\n \$('#repeat').click(function(){\n \$('#repeat').hide();\n \$('#playone').show();\n jwplayer().setRepeat();\n return false;\n })\n \$('#playone').click(function(){\n \$('#repeat').show();\n \$('#playone').hide();\n jwplayer().setRepeat();\n return false;\n })\n\n \$('#sequence').click(function(){\n isShuffle = true;\n \$('#sequence').hide();\n \$('#shuffle').show();\n jwplayer().setShuffle();\n return false;\n })\n \$('#shuffle').click(function(){\n isShuffle = false;\n \$('#sequence').show();\n \$('#shuffle').hide();\n jwplayer().setShuffle();\n return false;\n })\n function randomItem(){\n var playlist = jwplayer().getPlaylist();\n var playlistsize = playlist.length;\n var randomnumber=Math.floor(Math.random()*playlistsize)\n return randomnumber;\n };\n ", CClientScript::POS_END); $cs->registerScript('play_album_this' . $this->id, "\n function playThis(index) {\n\t\t\t\t\tjwplayer().playlistItem(index);\n };", CClientScript::POS_END); $cs->registerScript('play_album_getlyrics' . $this->id, "\n function getLyrics() {\n\t\t\t\t\tvar currentItem = jwplayer().getPlaylistItem();\n itemId = currentItem.mediaid;\n Popup.title_popup='Lời bài hát';\n var lyrics = \$('#lyrics-'+itemId).html();\n lyrics = (lyrics=='') ? 'Lời bài hát đang được cập nhật!' : lyrics;\n Popup.alert(lyrics);\n };", CClientScript::POS_END); $deviceType = 'mobile'; $cs->registerScript('play_album_current' . $this->id, "\n var device_type = '" . $deviceType . "';\n var listPlayed =Array();\n var logPlayAlbumFlag = true;\n var logSongFlag = true;\n jwplayer().onBeforePlay(function() {\n var currentItem = jwplayer().getPlaylistItem();\n itemId = currentItem.mediaid;\n \$('.nhacvnplayer ul li.item').removeClass('onpause');\n \$('.nhacvnplayer ul li.item').removeClass('playing');\n \$('.nhacvnplayer #song_'+itemId).addClass('playing');\n });\n jwplayer().onPause(function(){\n var currentItem = jwplayer().getPlaylistItem();\n itemId = currentItem.mediaid;\n \$('.nhacvnplayer ul li.item').removeClass('playing');\n \$('.nhacvnplayer #song_'+itemId).addClass('onpause');\n });\n\t\t\t\t\tjwplayer().onPlaylistItem(function() {\n\t\t\t\t\t logSongFlag = true;\n var currentItem = jwplayer().getPlaylistItem();\n itemId = currentItem.mediaid;\n //\$('.nhacvnplayer ul li.item').removeClass('playing');\n //\$('.nhacvnplayer #song_'+itemId).addClass('playing');\n hashdis = new Hashids(has_key);\n id = hashdis.encode(parseInt(itemId));\n songId = 'so'+id;\n\t history.replaceState({}, '', '?st='+songId);\n })\n //log and track\n jwplayer().onTime(function(event) {\n if(Math.round(event.position) >=5){\n if(logPlayAlbumFlag) {\n logPlayAlbumFlag = false;\n var action = 'Play Album';\n if(in_array_item(listPlayed,'album_'+" . $album->id . ")){\n var action = 'Replay Album';\n }\n var item = 'album_" . $album->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($album->name . "-" . $album->artist_name . "-" . $album->id) . "');\n ajax_load('/player/logAlbum',{'id':" . $album->id . "});\n }\n if(logSongFlag){\n logSongFlag = false;\n var currentItem = jwplayer().getPlaylistItem();\n itemId = currentItem.mediaid;\n itemTitle = currentItem.media_title;\n itemDesc = currentItem.media_desc;\n var action = 'Play Song';\n\t\t\t\t\t\t\tif(in_array_item(listPlayed,'song_'+itemId)){\n\t\t\t\t\t\t\t\tvar action = 'Replay Song';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar item = 'song_'+itemId;\n if(!in_array_item(listPlayed,item)){\n listPlayed.push(item);\n }\n //console.log(device_type+'-'+action+'|'+itemId+'|'+itemTitle+'|'+itemDesc);\n\t\t\t\t\t\t\tga('send', 'event', device_type, action, itemTitle+'-'+itemDesc+'-'+itemId);\n\t\t\t\t\t\t\tajax_load('/player/logSong',{'id':itemId});\n }\n }\n\n\t\t\t })", CClientScript::POS_END); if (isset($_GET['st']) && !empty($_GET['st'])) { $st = $_GET['st']; if (!is_numeric($st)) { $hashStrId = substr($st, 2); $hashids = new Hashids(Yii::app()->params["hash_url"]); $parse = $hashids->decode($hashStrId); $songId = $parse[0]; $index = isset($playlistIndex[$songId]) ? $playlistIndex[$songId] : 0; } else { $index = (int) ($st - 1); } if ($index >= 0) { $cs->registerScript('play_album_st' . $this->id, "\n var isFirst = true;\n jwplayer().playlistItem(" . $index . ");\n jwplayer().onQualityLevels(function(event){\n if(isFirst){\n isFirst=false;\n \$('.nhacvnplayer ul li.item').removeClass('playing');\n \$('.nhacvnplayer #playlist li.song-item-" . $index . "').addClass('onpause');\n }\n });\n ", CClientScript::POS_END); } } } parent::init(); }
public function actionLogAlbum() { $id = Yii::app()->request->getParam('id'); $album = AlbumModel::model()->findByPk($id); if (!Yii::app()->user->isGuest) { $activity = new UserActivityModel(); $activity->channel = 'wap'; $activity->user_id = Yii::app()->user->getId(); $activity->user_phone = Yii::app()->user->getState('phone'); $activity->loged_time = date('Y-m-d H:i:s'); $activity->activity = 'play_album'; $activity->obj1_id = $album->id; $activity->obj1_name = $album->name; $activity->obj1_url_key = $album->url_key; $activity->obj2_id = $album->artist_id; $activity->obj2_name = $album->artist_name; $ret = $activity->save(); if ($ret) { echo "1"; } else { echo CHtml::errorSummary($activity); } Yii::app()->end(); } echo ''; Yii::app()->end(); }
/** * function actionView * call to render detail album page */ public function actionView() { $albumId = (int) Yii::app()->request->getParam('id'); $album = WapAlbumModel::model()->available()->findByPk($albumId); if (!$album) { $this->forward("/site/error", true); } else { if ($album->status == 0) { $deactive = true; } } $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId); //samge artist $countAlbumsSameArtist = WapAlbumModel::model()->countAlbumsSameArtist($album->id, $album->artist_id); $albumPages = new CPagination($countAlbumsSameArtist); $pageSize = Yii::app()->params['pageSize']; $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); /* NEW */ $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId); $artistIds = ''; if ($artists) { foreach ($artists as $artist) { $artistIds .= ',' . $artist->artist_id; } } $artistIds = $artistIds != '' ? substr($artistIds, 1) : ''; $albumsSameArtist = WapAlbumModel::model()->getAlbumbyArtists($artistIds, $pageSize, $currentPage * $pageSize); /* END */ $phone = yii::app()->user->getState('msisdn'); $errorCode = 'success'; $errorDescription = ''; //for show price $favourite = Yii::app()->request->getParam('favourite', null); $phone = yii::app()->user->getState('msisdn'); $user_id = Yii::app()->user->id; if (isset($favourite) && $favourite == 0) { if (!empty($user_id)) { $res = WapFavouriteAlbumModel::model()->deleteAllByAttributes(array('msisdn' => $phone, 'album_id' => $albumId)); } else { $this->redirect($this->createUrl("/account/login")); } } if (isset($favourite) && $favourite == 1) { if (!empty($phone)) { $res = WapFavouriteAlbumModel::model()->favouriteAlbum($phone, $albumId); } else { $this->redirect($this->createUrl("/account/login")); } } $like = null; if ($phone) { $like = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $albumId, 'msisdn' => $phone)); } $userType = "GUEST"; $phone = Yii::app()->user->getState('phone'); if ($phone) { $userType = "MEMBER"; } $userSub = Yii::app()->user->getState('userSub'); $packageCode = Yii::app()->user->getState('packageCode'); if ($userSub) { $userType = "SUB_" . $packageCode; } $perLimit = ContentLimitModel::getPermision($albumId, "album", $userType, "WAP"); ///meta tag $AlbumDetail = AlbumModel::model()->findByPk($albumId); $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id; $ArtistInfo = ArtistModel::model()->findByPk($artistId); $this->itemName = $AlbumDetail->name; $this->artist = $ArtistInfo->name; $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1'); $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name)); $this->description = strip_tags($AlbumDetail->description); $this->render('view', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'albumsSameArtist' => $albumsSameArtist, 'albumPages' => $albumPages, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'userSub' => $userSub, 'like' => $like, 'perLimit' => $perLimit, 'deactive' => $deactive)); }
?> "> <div class="head-label clearfix"> <span class="text">Chủ đề âm nhạc</span> <span class="title"></span> </div><!-- End .head-label --> </a> <?php if ($topContent) { ?> <div class="box_content"> <ul class="collection_list items-list"> <?php foreach ($topContent as $item) { if (isset($item) && $item['type'] == 'album') { $albumInfo = AlbumModel::model()->findByPk($item['content_id']); $artist_name = $albumInfo->artist_name; $count = $albumInfo ? count($albumInfo->song_count) : 0; } elseif (isset($item) && $item['type'] == 'video_playlist') { $videoPlaylist = VideoPlaylistModel::model()->findByPk($item['content_id']); $artist_name = $videoPlaylist->artist_name; $count = $videoPlaylist ? count($videoPlaylist->video_playlist_videos) : 0; } else { $count = 0; } if ($count > 0 && $item['id'] != 0) { $link = Yii::app()->createUrl("topContent/view", array("id" => $item['id'], "title" => Common::makeFriendlyUrl($item['name']))); ?> <?php if (isset($item)) { ?>