Media对象不响应包含对象的cookie [英] Media object doesn't respond to cookie containing object

查看:90
本文介绍了Media对象不响应包含对象的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果问题非常愚蠢
我试图使用js显示从一个人到另一个用户的流

Sorry if the question is very stupid I am trying to show the stream from a person to another user using js

我试过把它放入一个cookie但它即使在那时也不起作用。即使视频中的对象与另一个相同

I have tried putting it in a cookie but it doesnt work even then.Even when the object in video is the same as the other

文件1

var video = document.querySelector("#videoElement");
var x=document.cookie
console.log(x)
video.srcObject = x;

文件2

var video = document.querySelector("#videoElement");

if (navigator.mediaDevices.getUserMedia) {
  navigator.mediaDevices.getUserMedia({ video: true })
    .then(function (stream) {
      video.srcObject = stream;
      document.cookie=video.srcObject 
      console.log(stream,video.srcObject)
    })
    .catch(function (err0r) {
      console.log("Something went wrong!");
    });
console.log(stream,video.srcObject)
}

我会喜欢现在只在两个页面上显示它,但是对于将来我应该使用什么语言存储视频,如果你知道你可以分享它

I would like to just for now show it on two pages but for future what language should i use to store the video if you know you can share it

推荐答案

Cookie不是网络上的集中式通用相机访问存储库。谢天谢地。

A cookie is not a centralized universal camera access repository on the web. Thank goodness.

A MediaStream 是表示活动相机使用的本地资源对象,而不是可共享网址

A MediaStream is a local resource object representing active camera use, not a shareable URL.

此对象仅存在于您当地JS页面,并且无法在网络上寻址。

This object lives solely in your local JS page, and isn't addressable on the web.

由于它不在任何服务器上运行,将图形位从相机传输到朋友的系统,需要相当多的举重。这包括建立 RTCPeerConnection ,它是 WebRTC

Since it doesn't live on any server, transporting the graphical bits from your camera to a friend's system, requires quite a bit of heavy lifting. This includes establishing an RTCPeerConnection which is the domain of WebRTC:

navigator.mediaDevices.getUserMedia({ video: true })
  .then(function (stream) {
    const iceServers = [{urls: "stun:stun.l.google.com:19302"}];
    const pc = new RTCPeerConnection({iceServers});

    for (const track of stream.getTracks())
      pc.addTrack(track, stream);

    /* lots of other WebRTC negotiation code */

您通常还需要某种服务器,两者都要解决发现,即联系人,以及一个Web套接字服务器,用于交换必要的批准要约/回答会话描述连接建立,在两个对等体之间。

You'll also typically need a server of some kind, both to solve discovery, i.e. point of contact, as well as a web socket server to exchange critcal offer/answer session descriptions that are necessary for connection establishment, between the two peers.

也许最简单的概念证明是这个cut'n'paste演示,它让您和朋友手动交换所需的WebRTC提供/回答会话描述,让您在没有任何服务器的情况下建立连接,以便彼此查看和交谈。

Perhaps the simplest proof of concept is this cut'n'paste demo, which let you and a friend exchange the required WebRTC offer/answer session descriptions manually, letting you establish a connection without any server, to see and talk to each other.

这有关于有70%的工作机会。如果你们都支持对称NAT(大多数移动网络),那么它会变得更难(你需要一台TURN服务器,需要花钱)。

That has about a 70% chance of working. If you're both behind symmetric NATs (most mobile networks), then it gets harder still (you'll need a TURN server, which costs money).

这篇关于Media对象不响应包含对象的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆