[英]Can I autoplay audio from a user interaction on a previous page on mobile?
I have an e-learning course that needs to autoplay audio with an animation on mobile. 我有一门电子学习课程,需要在移动设备上自动播放带有动画的音频。
I know that for IOS and Android autoplay requires a user interaction. 我知道,对于IOS和Android,自动播放需要用户互动。 How can I set it up so that that a click of next button on the previous page of the course will launch the audio on the following page? 如何设置它,以便单击课程上一页上的下一个按钮将在下一页上启动音频?
Here is code I have tried which works on desktop but seems like the user interaction is lost to mobile OS on the next page: 这是我尝试过的代码,可在台式机上使用,但在下一页上似乎失去了与用户的交互,而无法与移动操作系统进行交互:
$(document).ready(function() {
$('.NavigationButton').on('click touchend', function() {
//Internal Event that fires once content on next page is loaded
events.on('content.loaded', function () {
console.log( "window loaded" );
$("audio").trigger('play');
});
});
});
Is what I need to accomplish even possible? 我什至需要完成什么?
You can get around this issue using something like 您可以使用以下方法解决此问题:
$('#btn').click(function(){
yourAudioControl.play();
});
$('#btn').trigger('click');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.