实时播放视频

发布于 2025-01-09 12:34:07 字数 1270 浏览 1 评论 0原文

我想使用 webrtc 在不同网络(公共)上实时广播视频。我正在 github 上检查 TannerGabrriel Broadcast 代码! 这是代码:https://github.com/TannerGabriel/WebRTC-Video-Broadcast 我是 javascript 新手。我通常使用 python php html 但由于某种原因它让我很难理解 javascript。我尝试了屏幕共享,但它占据了整个屏幕!我只想播放视频,我的观众如何观看?

Html 部分

<video preload="auto" autoplay poster="./css/poster.jpg">
   <source src="./css/den.mp4" type="video/mp4"></source>
</video>

我从 youtube 获得了 JS,但我想在线播放它。实时...跟踪视频中的每个动作、、、快进、后退暂停!转到 12:21

(function(){
        var video = document.getElementById('video'),
            vendorUrl = wind.URL || window.webkitURL;
            
        navigator.getMedia = navigator.getUserMedia ||
                            navigator.webkitGetUserMedia ||
                            navigator.mozGetUserMedia ||
                            navigator.msGetUserMedia;
                            
        navigator.getMedia({
            video:true,
            audio:false
        }, function(stream){
            video.src =verndorUrl.createObjectURL(stream);
            video.play();
        }, function(error){
        
        });
    })();

Id like to broadcast the video realtime on different network(public) using webrtc. I am checking TannerGabrriel Broadcast code on github!
This is the code :https://github.com/TannerGabriel/WebRTC-Video-Broadcast
Im new in javascript.. I usually use python php html but it make very hard for me to understand javascript for some reason. I tried the screen share but it takes the whole screen! I only want the video to be broadcast, And how do my viewer to watch it?

Html part

<video preload="auto" autoplay poster="./css/poster.jpg">
   <source src="./css/den.mp4" type="video/mp4"></source>
</video>

I got the JS from youtube but Id like to stream it online. realtime... tracking each movement on this video,,, fast forward , backward pause! go to 12:21

(function(){
        var video = document.getElementById('video'),
            vendorUrl = wind.URL || window.webkitURL;
            
        navigator.getMedia = navigator.getUserMedia ||
                            navigator.webkitGetUserMedia ||
                            navigator.mozGetUserMedia ||
                            navigator.msGetUserMedia;
                            
        navigator.getMedia({
            video:true,
            audio:false
        }, function(stream){
            video.src =verndorUrl.createObjectURL(stream);
            video.play();
        }, function(error){
        
        });
    })();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2025-01-16 12:34:07

如果您只想播放视频,请在后端使用wrtc,通过它单个源可以将视频播放到多个接收端。不太可能 wrtc 是一个 Node js 包,并且不知道你的后端是由什么组成的

If you only want to broadcast a video, use wrtc on backend, with it single source can broadcast a video to multiple receiving ends. unlikely wrtc is an node js package and dont know what you're backend is made of

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文