For those who don't know SoundManager, SoundManager is a JavaScript Sound API supporting MP3, MPEG4 and HTML5 Audio. This widget is based on this demo example.
Yii 1.1 or above
<p><a href="/mp3/file1.mp3" id="singlePlayer_1" class="list1">Audio 1</a></p> <p><a href="/mp3/file2.mp3" id="singlePlayer_2" class="list1">Audio 2</a></p> <p><a href="/mp3/file3.mp3" id="singlePlayer_3" class="list1">Audio 3</a></p> <p><a href="/mp3/file4.mp3" id="singlePlayer_4" class="list1">Audio 4</a></p> <?php $this->widget("ext.SoundManager.ESoundManagerSimplePlayList", array("playListId"=>"playList1", "playListClass"=>"list1", "autoPlay"=>true, "autoNext"=>true, "playCallback"=>"onPlay", "stopCallback"=>"onStop", "pauseCallback"=>"onPause", "resumeCallback"=>"onResume", "finishCallback"=>"onFinish")); // Javascript to handle play event of the player $script = <<<EOD function onPlay(){ alert("Play: " + playList1.currentPlayerId); // playList1 is the id of the playlist parameter when we create the widget } function onStop(){ alert("Stop: " + playList1.currentPlayerId); // playList1 is the id of the playlist parameter when we create the widget } function onPause(){ alert("Pause: " + playList1.currentPlayerId); // playList1 is the id of the playlist parameter when we create the widget } function onResume(){ alert("Resume: " + playList1.currentPlayerId); // playList1 is the id of the playlist parameter when we create the widget } function onFinish(){ alert("Finish: " + playList1.currentPlayerId); // playList1 is the id of the playlist parameter when we create the widget } EOD; Yii::app()->clientScript->registerScript("playListEventHandler", $script);
Be the first person to leave a comment
Please login to leave your comment.