简体   繁体   English

如何在 html 中播放 RTMP stream 一旦它可用?

[英]How to play RTMP stream in html once it's available?

We have an RTMP stream from AWS IVS.我们有一个来自 AWS IVS 的 RTMP stream。

We are playing the RTMP stream in an HTML page using the following code from here :我们使用以下代码在 HTML 页面中播放 RTMP stream

if (IVSPlayer.isPlayerSupported) {
    const player = IVSPlayer.create();
    player.attachHTMLVideoElement(document.getElementById('video-player'));
    player.load(PLAYBACKURL);
    player.play();
}

This code works only when the RTMP stream is already playing.此代码仅在 RTMP stream 已经播放时有效。 If the stream from IVS is not ready when the html page is loaded, then the video is not played when it's ready.如果加载 html 页面时来自 IVS 的 stream 未准备就绪,则视频准备就绪时不会播放。 Hence the end user has to keep running this code (using a button for example)...因此,最终用户必须继续运行此代码(例如使用按钮)...

The ideal solution would be: when the RTMP stream is ready, play the video without the need of refreshing the page or running this code again.理想的解决方案是:当 RTMP stream 准备就绪时,无需刷新页面或再次运行此代码即可播放视频。

Does anyone know how to solve that please?请问有人知道如何解决吗?

Thanks.谢谢。

It's not something about playing RTMP in H5, it's about H5 <video> playing HLS, which is coverted by AWS IVS, because now H5 is not able to play RTMP.不是H5播放RTMP的问题,是H5 <video>播放HLS的问题,这被AWS IVS覆盖了,因为现在H5不能播放RTMP了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM