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.
Requirements ¶
Yii 1.1 or above
Usage ¶
<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);
?>
Using this widget without playlist
Hi, how can I use this widget without playlist? Basically I have many audio file with file names are primary key of a model and would like to display them in a CGridView table. Thank you!
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.