How do i sort out the loading delay with my stream? phonegap build
<audio id="stream" preload='none'>
<source src="http://195.10.228.6:8035/canal.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<a href="#" id="audioControl">play!</a>
<script>
var stream = document.getElementById('stream'),
ctrl = document.getElementById('audioControl');
ctrl.onclick = function () {
// Update the Button
var pause = ctrl.innerHTML === 'pause!';
ctrl.innerHTML = pause ? 'play!' : 'pause!';
// Update the Audio
var method = pause ? 'pause' : 'play';
stream[method]();
// Prevent Default Action
return false;
};
</script>
So the code above works fine in the way that it allows me to play/pause
the live stream of a radio show. However the only problem/minor issue is
to do with loading. You must wait on the app after it is opened to load
for around 10seconds all features of the app are accessible during this
time. Also if you hit the play button before the stream has loaded it
won't load unless the app is closed and re-opened. i've not tried it with
refreshing as i haven't built that feature in yet. So i'm not sure whether
that would work in the app.
Basically the question is how do i stop this delay? or allow it to load
during/after someone hits play?
phonegap build btw
No comments:
Post a Comment