gpt4 book ai didi

javascript - 通过webrtc传递上传的图片 - pubnub

转载 作者:行者123 更新时间:2023-11-28 07:27:19 26 4
gpt4 key购买 nike

我正在尝试实现一个网站,人们可以通过 html5 canvas 和 pubnub 进行绘图,并且每个人都可以看到其他人的绘图。到目前为止,一切都很好,唯一的问题是我希望人们能够上传图像,然后在它们上绘图(当然每个人都能够看到上传的图像)。
来自这篇文章here我上传了图像的一部分,但是当我上传图像时,其他用户不会发生这种情况。关于如何实现这一点有什么想法吗?

最佳答案

Get the PubNub WebRTC SDK - https://github.com/stephenlb/webrtc-sdk

WebRTC 照片共享无需 STUN 或 TURN

您可以轻松地从视频流中拍摄照片并立即发送给您的 friend 。您可以将其视为 Instagram WebRTC 风格。照片共享也可以通过企业防火墙进行。

WebRTC相机照片分享广播

phone.snap()

Broadcast your camera photo to all connected sessions. Also get the IMG data as base64 supported format for local display if desired.

phone.ready(function(){
// Auto Send Camera's Photo to all connected Sessions.
var photo = phone.snap();
$('#photo-div').append(photo.image);
});

WebRTC session 相机照片分享

session.snap()

Send your camera's latest frame as raw IMG to a specific call session.

phone.ready(function(){
var session = phone.dial('4321');
var photo = session.snap();
$('#photo-div').append(photo.image);
});

关于javascript - 通过webrtc传递上传的图片 - pubnub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29490634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com