Last active
October 6, 2015 09:04
-
-
Save satsalou/63d7aca282bef5ba3f1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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