首页 > 解决方案 > 播放来自其他来源的音频源时,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>

任何帮助表示赞赏。

标签: javascripthtmlsmart-tv

解决方案


推荐阅读