把本地电视台在Decentraland场景里的电视屏幕播放

in HIVE CN 中文社区4 years ago (edited)

image.png

最近在研究 Decentraland SDK 里 的 Video Texture , 发现它可以用 m3u8 的格式。 m3u8 是通常那些video live stream用的, 或是 IPTV 里也有用的一种直播格式。

我在这个 github 里 发现 有新加坡的电视节目的 m3u8 网址 , 也有其它国家的。
https://github.com/iptv-org/iptv

新加坡的电视频道就只有七个 :

两个中文频道 : 8频道,U频道,
两个英文频道 : 5频道, OKTO
新闻频道 : Channel News Asia
马来频道,和印度频道

比如说里面 Channel News Asia 的网址是 https://d2e1asnsl7br7b.cloudfront.net/7782e205e72f43aeb4a48ec97f66ebbe/index_5.m3u8

你可以先去 https://players.akamai.com/players/hlsjs testing 一下这个m3u8网址的直播是否可以正常播放, 可以后,
在把它加到 Decentraland 的video texture 里 。

首先在 resource 里添加所有你想播放的电视频道的网址,

image.png

然后弄一个material , texture 设去那个video texture

image.png

然后加入两个button 让参观你的场景的人可以按上下 button 切换频道。

image.png

这样,你就可以有一个电视机在你的虚拟场景了。 可以到 24,-147 去参观。

我发现使用上面那个m3u8 stream,在新加坡以外的朋友也依然可以看这到频道里的内容,

而官方的 mewatch.sg 都只限制给在新加坡境内的人观赏 (它是在网页上block )。


那Youtube 的视频 能导入到 decentraland 吗 ? 如果不是live 的话, 我发现它就不会是 m3u8 的格式,是 Live 的话,就可以。

不过,你把youtube 的网址放在 Decentraland 的话会遇到 CORS policy 的问题, 因为youtube 的 response header 没有加 allow origin:* (这个上次有讲过的 就是 abc.com 不可以跟xyz.com 做ajax request (xhr) 。 chrome 拿到response 后自己本身会drop 掉 如果 response header 没有设 allow origin: *, 感觉chrome 这个功能很多此一举 )

所以你可能要要求去参观你场景的人用这个

https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf

image.png

把chrome 的 CORS 关掉 , 才可以在 DCL 观赏 Youtube Live 的视频。

今天就分享到这

谢谢阅读 。

Sort:  

Congratulations @tensaix2j! You received a personal badge!

Happy Hive Birthday! You are on the Hive blockchain for 4 years!

You can view your badges on your board And compare to others on the Ranking

Do not miss the last post from @hivebuzz:

Hive Whale - Make it spray and get your badge!
Support the HiveBuzz project. Vote for our proposal!