Skip to content

Instantly share code, notes, and snippets.

@skounis
Created October 5, 2015 10:41
Show Gist options
  • Save skounis/1454f29a10fceea563e9 to your computer and use it in GitHub Desktop.
Save skounis/1454f29a10fceea563e9 to your computer and use it in GitHub Desktop.
Shoutcast Ionic Tutorial - Stream Controller
.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;
});
}
}
@savkelita
Copy link

stop/pause button doesn't work on android/ios devices. is there any solution how to fix it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment