音频适用于计算机浏览器,但不适用于移动设备

时间:2016-08-17 19:35:38

标签: javascript ruby-on-rails audio

我正在使用javascript在基于Rails构建的Web应用程序中播放.m4a音频文件。音频在电脑上播放得很好。但是,在移动浏览器上却没有。 我该如何解决这个问题?是因为我使用的是.m4a吗? 谢谢!!

仅关注app / views / people / new.html.erb和app / views / show.html.erb。

这是 app / views / people / new.html.erb

<div class="row">
<div class= "columns large-6">
<%= image_tag("trump.gif", size: "800x800", :id => "image0") %>
<%= audio_tag("welcome.m4a", autoplay: true, controls: false) %>
</div>
<div class="columns large-6">
<br>
<h3 class="gold">
<center>WANT TO KNOW WHAT TRUMP THINKS OF YOU?</center></h3>
<%= render 'form' %>
</div>
</div>

<div class="centerImg">
</div>
 <script>
 setTimeout(
function(){ 

$('#image0').attr( "src" , "<%= image_path "trump_final.png", :id => "image0" %>" );

// Play audio
//document.getElementById("staticImg").src = "trump.png"
//nameFunction(); should be called in syncronisation with (or at the end of audio1 playing)
 // Sixth setTimeout       
 //nameFunction(); should be called in syncronisation with (or at the end of audio1 playing)
 // Sixth setTimeout       
 //nameFunction(); should be called in syncronisation with (or at the end of audio1 playing)
// Sixth setTimeout       
 }, 2500);
</script>

0 个答案:

没有答案