Skip to content

Instantly share code, notes, and snippets.

@satsalou
Last active October 6, 2015 09:04
Show Gist options
  • Save satsalou/63d7aca282bef5ba3f1b to your computer and use it in GitHub Desktop.
Save satsalou/63d7aca282bef5ba3f1b to your computer and use it in GitHub Desktop.
.controller('StreamController', function() {
var isPlaying = false;
var stream;
var vm = angular.extend(this, {
togglePlay: togglePlay,
isPlaying: isPlaying
});
// ********************************************************************
function togglePlay() {
if (vm.isPlaying) {
pause();
} else {
play();
}
vm.isPlaying = isPlaying = !isPlaying;
}
function play() {
try {
stream = new window.Stream('http://stream-dc1.radioparadise.com/mp3-128');
// Play audio
stream.play();
} catch (Error) {
alert(Error);
}
}
function pause() {
if (!stream) {
return;
}
stream.stop();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment