I am trying following function.
Smartphone access a certain web page and preload the audio. From the browser of PC send a signal to smartphones to start playing audio.
I understand that iPhones never preload the audio file. So I invoke audio.load() when button is touched by user.
I just want to preload the data ,don't want to play. I tested following iOS version but only iOS7.1.1 starts playing. Does anybody have idea to force it to just load and not start playing ?
iphone4 with iOS5.1.1 iPhone4 with iOS6.1.3 iphone5 with iOS 7.1.1 (*) iphone5c with iOS8.1.1
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>SOCKET</title>
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="/http://ift.tt/1aeIZU4"></script>
<script>
$(function() {
// run on page load
var button = document.getElementById('button');
var audio = document.getElementById('audio');
var onClick = function() {
audio.load()
};
button.addEventListener('click', onClick, false);
var socket = io.connect();
socket.on('emit_from_server',function(data){
$('#logs').append($('<li>').text(data));
if (data == 'play' && audio.paused){
audio.play();
}
});
});
</script>
<p><audio id="audio" src="/iphone-oche-piano.mp3" controls></audio></p>
Your are Player
<button id="button">Play</button>
<ul id="logs"></ul>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire