Created
October 5, 2015 10:41
-
-
Save skounis/1454f29a10fceea563e9 to your computer and use it in GitHub Desktop.
Shoutcast Ionic Tutorial - Stream Controller
This file contains hidden or 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($interval, streamService) { | |
var isPlaying = false; | |
var stream; | |
var timer; | |
var vm = angular.extend(this, { | |
togglePlay: togglePlay, | |
isPlaying: isPlaying, | |
info: null | |
}); | |
// ********************************************************************* | |
function togglePlay() { | |
if (vm.isPlaying) { | |
pause(); | |
} else { | |
play(); | |
} | |
vm.isPlaying = isPlaying = !isPlaying; | |
} | |
function play() { | |
if (window.Stream) { | |
stream = new window.Stream('http://198.100.125.242:80/'); | |
// Play audio | |
stream.play(); | |
} | |
getStreamInfo(); | |
timer = $interval(function() { | |
getStreamInfo(); | |
}, 5000); | |
} | |
function pause() { | |
vm.info = null; | |
$interval.cancel(timer); | |
if (!stream) { | |
return; | |
} | |
stream.stop(); | |
} | |
function getStreamInfo() { | |
streamService.getStreamInfo().then(function(info) { | |
vm.info = info; | |
}, function() { | |
vm.info = null; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stop/pause button doesn't work on android/ios devices. is there any solution how to fix it ?