javascript - 播放来自其他来源的音频源时,Smart TV Internet Browser 会停止播放视频。有没有办法在没有视频“黑屏”的情况下播放音频?
问题描述
这个问题不会发生在 iPhone 浏览器、PC 上的 Chrome、Microsoft Edge 等,而只会发生在智能电视互联网浏览器上(据我所知)。这发生在我的 LG 电视内置互联网应用程序以及我尝试过的另一个智能电视(索尼)互联网浏览器应用程序上。视频将播放(即 id='myVideo'),并且当单独的音频播放器(即 id='myAudio、id='myAudio2 或 id='myAudio3)开始播放时(即当按钮“单击”告诉音频'play'),视频变为黑色并保持这种状态,直到请求再次播放视频源。当 myVideo 再次“播放”时,视频会重新开始。
这是示例代码:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="euc-jp">
</head>
<body>
<video controls loop id="myVideo">
<source src="https://www.w3schools.com/html/movie.mp4">
</video><br>
<button onClick="play()">Video Play</button>
<br><br>
<audio controls id="myAudio">
<source src="https://www.w3schools.com/html/horse.mp3">
</audio>
<script>
function play() {
document.getElementById("myVideo").play();
}
document.getElementById("myAudio").addEventListener("ended",
function() {
document.getElementById("myAudio").currentTime = "0"; //this added because on my LG smart TV, the audio can only be played once, after that the audio does not return to the start position.
}
);
</script>
</body>
</html>
任何帮助表示赞赏。
解决方案
推荐阅读
- python - Django MOD_WSGI 设置?MOD_WSGI Apache2 403 您无权访问此资源
- javascript - 在 MERN 中定义新用户时,MERN 堆栈中出现 500 内部服务器错误
- javascript - 如何将事件侦听器添加到画布上绘制的矩形?
- c# - 使用 SqlDataReader 从不同的结果集中读取数据
- sql-server - 我们可以在存储过程中根据某些条件添加多个更新语句吗
- mysql - 结合 ORDER BY FIELD 和另一个查询
- azure - Mac 上的 AzureAD Powershell
- python - 将 4 列合并为两列
- java - Java ArrayList 不断重复值直到数组结束
- ethereum - 如何为当前未知的合约编写合约调用?