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 actionViewType() { $artistId = Yii::app()->request->getParam('id'); $artist = ArtistModel::model()->findByPk($artistId); $this->artist = $artist->name; $this->thumb = ArtistModel::model()->getAvatarUrl($artist->id, 150); $this->url = URLHelper::buildFriendlyURL("artist", $artist->id, $artist->url_key); if (!$artist) { $this->forward("/site/error", true); } $listType = Yii::app()->request->getParam('list', 'song'); $countSongsOfArtist = $artist->song_count; $countClipsOfArtist = $artist->video_count; $countAlbumsOfArtist = $artist->album_count; $pageSize = Yii::app()->params['numberSongsPerPage']; if ($listType == 'song') { // in case that list songs of artist $songPages = new CPagination($countSongsOfArtist); $songPages->setPageSize($pageSize); $currentPage = $songPages->getCurrentPage(); $songsOfArtist = WapSongModel::model()->getSongsSameSinger(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'songsOfArtist' => $songsOfArtist, 'songPages' => $songPages)); } elseif ($listType == 'clip') { // in case that list clips of artist $clipPages = new CPagination($countClipsOfArtist); $clipPages->setPageSize($pageSize); $currentPage = $clipPages->getCurrentPage(); $clipsOfArtist = WapVideoModel::model()->getVideosSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'clipsOfArtist' => $clipsOfArtist, 'clipPages' => $clipPages)); } else { // in case that list albums of artist $albumPages = new CPagination($countAlbumsOfArtist); $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); $albumsOfArtist = WapAlbumModel::model()->getAlbumsSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'albumsOfArtist' => $albumsOfArtist, 'albumPages' => $albumPages)); } }
public function publishAssets() { if ($this->freeWifi) { if (!Yii::app()->user->getState('is3G')) { $localConfig = (require Yii::getPathOfAlias('application.config') . '/local.php'); Yii::app()->params['storage'] = $localConfig['params']['storage']; } } $list = ""; $deviceId = yii::app()->session['deviceId']; $deviceProfile = SongModel::model()->getSongProfileIdSuport($deviceId, 'http'); foreach ($this->songList as $song) { //$audioTest = 'http://audio.chacha.vn/songs/output/22/184609/4.mp3'; $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'http', $song->profile_ids, $deviceProfile); $playeCount = $song->song_statistic ? $song->song_statistic->played_count : 0; $songName = str_replace("'", "\\'", $song->name); $songArtist = str_replace("'", "\\'", $song->artist_name); $list .= "{\n\t\t\t\ttitle:'{$songName}',\n\t\t\t\tmp3:'{$playUrl}',\n\t\t\t\tsong_id:'{$song->id}',\n\t\t\t\tartist:'{$songArtist}',\n\t\t\t\tplay_count:'{$playeCount}',\n\t\t\t },"; } $this->listJs = $list; Yii::app()->clientScript->registerCoreScript('jquery'); Yii::app()->clientScript->registerCoreScript('jquery.ui'); $assets = dirname(__FILE__) . '/assets'; $baseUrl = Yii::app()->assetManager->publish($assets); $this->basePath = $baseUrl; if (is_dir($assets)) { //Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jquery.jplayer.min.js', CClientScript::POS_HEAD); Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jquery.jplayer.js', CClientScript::POS_HEAD); //Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jplayer.playlist.min.js', CClientScript::POS_HEAD); Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jplayer.playlist.js', CClientScript::POS_HEAD); Yii::app()->clientScript->registerScriptFile($baseUrl . '/player.js', CClientScript::POS_HEAD); Yii::app()->clientScript->registerCssFile($baseUrl . '/skin/jplayer-custom.css'); Yii::app()->clientScript->registerCssFile($baseUrl . '/skin/jplayer.blue.monday.css'); Yii::app()->clientScript->registerCssFile('http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css'); } else { throw new CHttpException(500, 'Player - Error: Couldn\'t find assets to publish.'); } }
/** * bai hat yeu thich */ public function actionFavSong() { $phone = yii::app()->user->getState('msisdn'); $cri = new CDbCriteria(); $cri->condition = " phone = {$phone}"; $user = UserModel::model()->find($cri); $uid = $user->id; $limit = Yii::app()->params['pageSize']; $pageSize = Yii::app()->params['pageSize']; $page = Yii::app()->request->getParam('page', 1); $offset = ($page - 1) * $limit; $countSong = WapSongModel::model()->countFavSong($uid); $songPages = new CPagination($countSong); $songPages->setPageSize($pageSize); $favsong = WapSongModel::model()->getFavSong($phone, $limit, $offset); $headerText = Yii::t('chachawap', 'Bài hát yêu thích'); $link = Yii::app()->createUrl("/account/favsong"); $this->render('songlist', array('songs' => $favsong, 'link' => $link, 'type' => "list", 'headerText' => $headerText, 'songPages' => $songPages)); }
public function actionDownload() { $this->layout = false; $contentId = (int) Yii::app()->request->getParam('id'); $type = Yii::app()->request->getParam('type', 'downloadSong'); $deviceId = yii::app()->session['deviceId']; $downloadUrl = ''; if ($type == 'downloadVideo') { $video = WapVideoModel::model()->findByPk($contentId); $downloadUrl = VideoModel::model()->getDownloadUrl($contentId, $deviceId, 'http', true); $contentType = 'video/mp4'; $fileName = $video->name; $fileName = Common::makeFriendlyUrl($fileName) . ".mp4"; } elseif ($type == 'downloadSong') { $song = WapSongModel::model()->findByPk($contentId); //$downloadUrl = WapSongModel::model()->getNiceDownloadUrl($song->id, $deviceId, 'http', $song->profile_ids, $song->url_key, $song->artist_name); //$downloadUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'http', $song->profile_ids); $downloadUrl = WapSongModel::model()->getNiceDownloadUrl($song->id, $deviceId, 'http', $song->profile_ids, $song->url_key, $song->artist_name); echo '<meta http-equiv="refresh" content="0;url=' . $downloadUrl . '" />'; exit; $contentType = 'audio/mpeg'; $fileName = $song->name; $fileName = Common::makeFriendlyUrl($fileName) . ".mp3"; } echo '<meta http-equiv="refresh" content="0;url=' . $downloadUrl . '" />'; exit; //$this->redirect($downloadUrl); //Yii::app()->end(); //echo '<meta http-equiv="refresh" content="0;url='.$downloadUrl.'" />'; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=" . $fileName); header("Content-Type: {$contentType}"); header("Content-Transfer-Encoding: binary"); readfile($downloadUrl); //Yii::app()->end(); //Common::DownloadWithName($this->userPhone, $contentId, $type); exit; }
<?php if ($topContent->type == 'album') { $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($topContent->content_id, "album", $userType, "WAP"); $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($topContent->content_id); $like = null; if ($phone) { $userId = WapUserModel::model()->findByAttributes(array('phone' => $phone))->id; $like = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $albumId, 'msisdn' => $phone)); } $this->renderPartial('_albumView', compact('content', 'perLimit', 'songsOfAlbum', 'like')); } elseif ($topContent->type == 'video_playlist') { $list_video_playlist = WapVideoModel::model()->getVideosOfVideoPlaylist($topContent->content_id); //check noi dung doc quyen $userType = "GUEST"; $phone = Yii::app()->user->getState('phone'); if ($phone) { $userType = "MEMBER"; } $userSub = Yii::app()->user->getState('userSub'); $packageCode = Yii::app()->user->getState('packageCode');
public function actionCharge() { $id = Yii::app()->request->getParam('id'); $song = SongModel::model()->findByPk($id); $action = Yii::app()->request->getParam('action', 'playSong'); $deviceId = yii::app()->session['deviceId']; $msg = ""; $playUrl = ''; if (!$song) { $this->forward("/site/error", true); } $artist_name = Common::makeFriendlyUrl($song->artist_name); $back_url = Yii::app()->params['base_url'] . Yii::app()->createUrl('song/view', array('id' => $song->id, 'url_key' => Common::makeFriendlyUrl($song->name), 'artist' => $artist_name)); if (Yii::app()->user->isGuest) { if ($action == 'downloadSong') { $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url))); Yii::app()->end(); } else { //cho nghe 5 lan free $limit = isset(Yii::app()->session["limit_play"]) ? Yii::app()->session["limit_play"] : 0; if ($limit >= 5) { $msg = Yii::app()->params['message']['limit_content']; } else { Yii::app()->session["limit_play"] = Yii::app()->session["limit_play"] + 1; $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'rtsp', $song->profile_ids); $this->redirect($this->createUrl("song/view", array('url' => $playUrl, "id" => $id, 'url_key' => $song->url_key))); } $this->render('play', compact('msg', 'back_url', 'playUrl')); exit; } } if ($action == 'downloadSong' && empty($this->isSub)) { $msg = "Quý khách vui lòng đăng ký dịch vụ để tải miễn phí nội dung"; $this->render('download', compact('msg', 'back_url')); exit; } $bmUrl = Yii::app()->params['bmConfig']['remote_wsdl']; $client = new SoapClient($bmUrl, array('trace' => 1)); if ($action == 'downloadSong') { $params = array('code' => $song->code, 'from_phone' => yii::app()->user->getState('msisdn'), 'to_phone' => yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0, 'smsId' => '', 'noteOptions' => array()); $result = $client->__soapCall('downloadSong', $params); } elseif ($action == 'playSong') { $params = array('code' => $song->code, 'from_phone' => Yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0); $result = $client->__soapCall('playSong', $params); } $errorCode = $result->message; // Log url trả về cho user if ($errorCode == "success") { if ($action == 'playSong') { $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'rtsp', $song->profile_ids); } else { $playUrl = WapSongModel::model()->getNiceDownloadUrl($song->id, $deviceId, 'http', $song->profile_ids, $song->url_key, $song->artist_name); } $this->redirect($this->createUrl("song/view", array('url' => $playUrl, "id" => $id, 'url_key' => $song->url_key))); } else { $msg = Yii::app()->params['subscribe'][$errorCode]; } $this->render('play', compact('msg', 'back_url', 'playUrl')); }
<?php $is_user = !Yii::app()->user->isGuest ? "before-load" : ""; if (!Yii::app()->user->isGuest || $free) { $deviceId = yii::app()->session['deviceId']; $playUrl = WapSongModel::model()->getAudioFileUrl($this->song->id, $deviceId, 'http', $this->song->profile_ids); ?> <script type="text/javascript"> var firstclick = 0; var success = 0; var inti; $(document).ready(function() { var audio = document.getElementById("new_audio"); // neu sau 10 giay ko load dc File thi Hide Player inti = setInterval(function(){ if (audio.networkState!=1 && audio.networkState!=2){ inti = window.clearInterval(inti); $(".li_play").hide();$(".li_pause").hide(); } },10000); }); function playSong(){ if($("#auto-play").hasClass("before-load")) return false; if(success == 1){ successPlay(); } if(firstclick==0){ $.ajax({ type: "GET", url: "<?php
/** * 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)); }
$(document).ready(function(){ var albumObj = { id:<?php echo $this->album->id; ?> , name:"<?php echo CHtml::encode($this->album->name); ?> ", listSong:{} }; listSong = Array(); <?php foreach ($this->songs as $key => $song) { $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, '', 'http', $song->profile_ids); ?> var item = { title: "<?php echo $song->name; ?> ", mp3: "<?php echo $playUrl; ?> ", id: <?php echo $song->id; ?> , code: '<?php