/*testclient*/
function OnStart () {
new audioPlayer();
audioPlayer.buildLayout();
}
function audioPlayer() {
app.SetOrientation("landscape")
audioPlayer.fileName = this.fileName || ""
audioPlayer.format = this.format || ""
audioPlayer.type = this.type || ""
audioPlayer.LoadAudio = function (fileName){
this.fileName = fileName || audioPlayer.fileName;
return this.fileName ;
}
audioPlayer.buildLayout = function (){
audioPlayer.mediaplayer = app.CreateMediaPlayer();
audioPlayer.mediaplayer.SetFile(audioPlayer.fileName);
audioPlayer.layoutControls = app.CreateLayout("linear","Horizontal,FillXY");
audioPlayer.layoutControls.SetGravity("HCenter");
audioPlayer.mainLayout = app.CreateLayout("linear","Vertical");
audioPlayer.btnReset = app.CreateButton("[fa-step-backward]",-1,-1,"FontAwesome");
audioPlayer.btnReset.SetOnTouch(function () {audioPlayer.btnstouch("reset")});
audioPlayer.btnRewind = app.CreateButton("[fa-backward]",-1,-1,"FontAwesome");
audioPlayer.btnRewind.SetOnTouch(function () {audioPlayer.btnstouch("rewind")});
audioPlayer.btnPlay = app.CreateButton("[fa-play]",-1,-1,"FontAwesome");
audioPlayer.btnPlay.SetOnTouch(function () {audioPlayer.btnstouch("play")});
audioPlayer.btnPause = app.CreateButton("[fa-pause]",-1,-1,"FontAwesome");
audioPlayer.btnPause.SetOnTouch(function () {audioPlayer.btnstouch("pause")});
audioPlayer.btnStop = app.CreateButton("[fa-stop]",-1,-1,"FontAwesome");
audioPlayer.btnStop.SetOnTouch(audioPlayer.btnsontouch);
audioPlayer.btnStop.SetOnTouch(function () {audioPlayer.btnstouch("stop")});
audioPlayer.btnFastForward = app.CreateButton("[fa-forward]",-1,-1,"FontAwesome");
audioPlayer.btnFastForward.SetOnTouch(function () {audioPlayer.btnstouch("forward")});
audioPlayer.btn = app.CreateButton("[fa-forward]",-1,-1,"FontAwesome");
audioPlayer.btnFastForward.SetOnTouch(function () {audioPlayer.btnstouch("forward")});
//"/sdcard/Download/Scripts/IMG_0939.MOV"
audioPlayer.btnFastForward = app.CreateButton("[fa-forward]",-1,-1,"FontAwesome");
audioPlayer.btnFastForward.SetOnTouch(function () {audioPlayer.btnstouch("forward")});
audioPlayer.btnLoad = app.CreateButton("[fa-folder-open]",-1,-1,"FontAwesome");
audioPlayer.btnLoad.SetOnTouch(function () {audioPlayer.btnstouch("load");});
audioPlayer.duration = audioPlayer.mediaplayer.GetDuration()
audioPlayer.barSeek = app.CreateSeekBar(1,-1);
audioPlayer.barSeek.SetRange(1.0);
audioPlayer.barSeek.SetOnTouch(function () {audioPlayer.btnstouch("seek");});
audioPlayer.trackInfoLabel = app.CreateList("Track Info:");
audioPlayer.trackInfoLabel.SetEnabled(false)
audioPlayer.trackInfo = app.CreateText("");
audioPlayer.trackInfo.SetTextSize(14.4)
audioPlayer.trackFormatLabel = app.CreateList("Track Format:");
audioPlayer.trackFormatLabel.SetEnabled(false);
audioPlayer.trackFormat = app.CreateText("");
audioPlayer.trackFormat.SetTextSize(14.4)
audioPlayer.layoutControls.AddChild(audioPlayer.btnReset);
audioPlayer.layoutControls.AddChild(audioPlayer.btnRewind);
audioPlayer.layoutControls.AddChild(audioPlayer.btnPlay);
audioPlayer.layoutControls.AddChild(audioPlayer.btnPause);
audioPlayer.layoutControls.AddChild(audioPlayer.btnStop);
audioPlayer.layoutControls.AddChild(audioPlayer.btnFastForward);
audioPlayer.mainLayout.AddChild(audioPlayer.layoutControls);
audioPlayer.layoutControls.AddChild(audioPlayer.btnLoad);
audioPlayer.mainLayout.AddChild(audioPlayer.barSeek);
audioPlayer.mainLayout.AddChild(audioPlayer.trackInfoLabel);
audioPlayer.mainLayout.AddChild(audioPlayer.trackInfo);
audioPlayer.mainLayout.AddChild(audioPlayer.trackFormatLabel);
audioPlayer.mainLayout.AddChild(audioPlayer.trackFormat)
app.AddLayout(audioPlayer.mainLayout);
}
audioPlayer.update = function () {
if( audioPlayer.mediaplayer.GetDuration())
audioPlayer.barSeek.SetValue( audioPlayer.mediaplayer.GetPosition() / audioPlayer.mediaplayer.GetDuration());
}
audioPlayer.btnstouch = function (title){
switch(title){
case "reset":
audioPlayer.mediaplayer.SeekTo(0);
break;
case "rewind":
audioPlayer.mediaplayer.SeekTo(audioPlayer.mediaplayer.GetPosition() - 30);
break;
case "play":
audioPlayer.mediaplayer.Play();
break;
case "pause":
audioPlayer.mediaplayer.Pause();
break;
case "stop":
audioPlayer.mediaplayer.Stop();
break;
case "forward":
audioPlayer.mediaplayer.SeekTo(audioPlayer.mediaplayer.GetPosition() + 30 );
break;
case "load":
app.ChooseFile(null,"", function (fileName) {
audioPlayer.mediaplayer.SetFile(fileName);
var trackFormat= fileName.substring(fileName.lastIndexOf( ".") + 1)
var trackName = fileName.substring(fileName.lastIndexOf( "/")+ 1, fileName.lastIndexOf( "."))
audioPlayer.trackInfo.SetText(trackName);
audioPlayer.trackFormat.SetText(trackFormat);
audioPlayer.mediaplayer.Play();
})
break;
case "seek":
audioPlayer.mediaplayer.SeekTo( audioPlayer.mediaplayer.GetDuration() * audioPlayer.barSeek.GetValue() );
setInterval( "audioPlayer.update()", 1000);
break;
}//end.switch
}//end audioPlayer.btnstouch
} //audioPlayer.end
Here is the basic code I put together just to get it working basic through steaming a remote file url (it was in the examples section from the site listed above).
It seems to have a lot of UI features and plugins that seem really great for DJ apps.
Hope that helps!
code:
<html>
<head>
<meta name="viewport" content="width=device-width">
<script src='file:///android_asset/app.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/wavesurfer.js/2.0.6/wavesurfer.min.js"></script>
</head>
<script>
//Called after application is started.
function OnStart()
{
var wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'violet',
progressColor: 'purple'
});
wavesurfer.load('http://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3')
wavesurfer.on('ready', function () {
wavesurfer.play();
});
}
</script>
<style>
</style>
<body onload="app.Start()">
<div id="waveform"></div>
</body>
</html>
I don't know another way at the moment sorry :/