简体   繁体   English

我想在我的应用程序上进行 m3u8 直播。 那么任何人都可以帮助我如何做到这一点? 我尝试使用 exoplayer 但我失败了

[英]i want to do m3u8 live streaming on my app. So can anyone help me how can i do this ? i tried with exoplayer but i failed

I want to develop a live streaming app with exoplayer, I tried with exo player but i failed to do this.我想用 exoplayer 开发一个实时流媒体应用程序,我尝试使用 exo player 但我没有做到这一点。 can anyone help me to do this,, ?谁能帮我做到这一点,,?

Yes, I can help, there is a tool that is called HLS.js.是的,我可以帮忙,有一个名为 HLS.js 的工具。 You can embed any stream with m3u8 extension with this tool, here it is the link: HLS.js您可以使用此工具嵌入任何带有 m3u8 扩展名的 stream,这是链接: HLS.js

If your stream is insecure you need to use an http website if it's not you can use https .如果您的 stream 不安全,您需要使用http网站,如果不是,您可以使用https I will give for you an example code:我会给你一个示例代码:

<script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>
<!-- Or if you want the latest version from the main branch -->
<!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@canary"></script> -->
<video id="video"></video>
<script>
  var video = document.getElementById('video');
  var videoSrc = 'YOUR-STREAM-SOURCE';
  if (Hls.isSupported()) {
    var hls = new Hls();
    hls.loadSource(videoSrc);
    hls.attachMedia(video);
  }
  // HLS.js is not supported on platforms that do not have Media Source
  // Extensions (MSE) enabled.
  //
  // When the browser has built-in HLS support (check using `canPlayType`),
  // we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video
  // element through the `src` property. This is using the built-in support
  // of the plain video element, without using HLS.js.
  //
  // Note: it would be more normal to wait on the 'canplay' event below however
  // on Safari (where you are most likely to find built-in HLS support) the
  // video.src URL must be on the user-driven white-list before a 'canplay'
  // event will be emitted; the last video event that can be reliably
  // listened-for when the URL is not on the white-list is 'loadedmetadata'.
  else if (video.canPlayType('application/vnd.apple.mpegurl')) {
    video.src = videoSrc;
  }
</script>

If this extension can be played on any device the video will have the same source as your stream.如果此扩展程序可以在任何设备上播放,则视频将与您的 stream 具有相同的源。

Hope I have helped!希望我有帮助!

暂无
暂无

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

相关问题 我想通过在当前应用程序中按一个按钮来终止/关闭特定应用程序。 我怎样才能做到这一点? - I want to kill/ close a particular app by pressing a button in my current app. How can I do this? 我正在努力使我的应用程序具有“保持登录状态”状态。 我该怎么办? - I'm working on having a “Keep me on Logged in” state on my app. How should i do it? 我想从我的Java Web应用程序访问他们自己的保管箱的用户。 我怎样才能做到这一点? - I want to give access to users of their own dropbox from my java web app. How can I do that? 排序数组 - 任何人都可以帮我解决我失败的地方吗? - Sorting array - Can anyone help me where I'm failing? .m3u8 直播视频无法在 exoplayer 上播放 - .m3u8 live video isn't streaming on exoplayer 您好,亲爱的,我将我的应用程序附加到 firbase adabase,所以它崩溃了。 我已经尝试了太多来解决这个问题,但无法摆脱请帮助我 - Hello Dear, I attach my app with firbase adabase so it crashes. I have tried too much to sort out of this Problem but can't get rid of please help me 我尝试在我的小型 android 项目中使用意向电子邮件,但它不起作用。 谁能帮我找出错误? - I tried to use intent email in my small android project but its not working. Can anyone help me to find the error? 我想显示在我的 while 循环中输入的每个数字。所以我该怎么做 - i want to display every number entered in my while loop.so how can i do this 任何人都可以帮助我解释为什么我的Java方法不能完全按照我的期望去做吗? - Could anyone help me with why my Java method isn't quite doing what I'm expecting it to do? 我想将聊天窗口/选项集成到我的 web 应用程序中。 我从哪说起呢? - I want to integrate a chat window/option into my web app. Where do I start?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM