This page is a browser based media player.
This demo is using the cordova-plugin-media plugin. For more information click here:
var GSW = GSW || {};
GSW.Tests = GSW.Tests || {};
GSW.Tests.onDeviceReady = function() {
// Cordova is now initialized. Have fun!
console.log('Now running cordova-' + cordova.platformId + '@' + cordova.version);
var myMedia = null;
GSW.Tests.playAudio = function() {
console.log("check 1");
var src = "https://sshserver.com/android/piano.mp3";
if (myMedia === null) {
myMedia = new Media(src, GSW.Tests.onSuccess, GSW.Tests.onError);
GSW.Tests.onSuccess = function() {
console.log("playAudio Success");
}
GSW.Tests.onError = function(error) {
console.log("playAudio Error: " + error.code);
}
}
myMedia.play();
}
GSW.Tests.pauseAudio = function() {
if (myMedia) {
myMedia.pause();
}
}
GSW.Tests.stopAudio = function() {
if (myMedia) {
myMedia.stop();
}
myMedia = null;
}
var volumeValue = 0.5;
GSW.Tests.volumeUp = function() {
if (myMedia && volumeValue < 1) {
myMedia.setVolume(volumeValue += 0.1);
}
}
GSW.Tests.volumeDown = function() {
if (myMedia && volumeValue > 0) {
myMedia.setVolume(volumeValue -= 0.1);
}
}
document.getElementById("playAudio").addEventListener("click", GSW.Tests.playAudio);
document.getElementById("pauseAudio").addEventListener("click", GSW.Tests.pauseAudio);
document.getElementById("stopAudio").addEventListener("click", GSW.Tests.stopAudio);
document.getElementById("volumeUp").addEventListener("click", GSW.Tests.volumeUp);
document.getElementById("volumeDown").addEventListener("click", GSW.Tests.volumeDown);
}
document.addEventListener('deviceready', GSW.Tests.onDeviceReady, false);