mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-13 19:22:05 +00:00
Accepts whep from streem.vereto.net
This commit is contained in:
parent
bb5173fd12
commit
f12115159e
5 changed files with 58 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ var order = [
|
||||||
'playerjs.coffee',
|
'playerjs.coffee',
|
||||||
'iframechild.coffee',
|
'iframechild.coffee',
|
||||||
'odysee.coffee',
|
'odysee.coffee',
|
||||||
|
'whepplayer.coffee',
|
||||||
'streamable.coffee',
|
'streamable.coffee',
|
||||||
|
|
||||||
// iframe embed-based players
|
// iframe embed-based players
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ TYPE_MAP =
|
||||||
bc: IframeChild
|
bc: IframeChild
|
||||||
bn: IframeChild
|
bn: IframeChild
|
||||||
od: OdyseePlayer
|
od: OdyseePlayer
|
||||||
|
wp: WhepPlayer
|
||||||
nv: NicoPlayer
|
nv: NicoPlayer
|
||||||
|
|
||||||
window.loadMediaPlayer = (data) ->
|
window.loadMediaPlayer = (data) ->
|
||||||
|
|
|
||||||
46
player/whepplayer.coffee
Normal file
46
player/whepplayer.coffee
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
window.WhepPlayer = class WhepPlayer extends PlayerJSPlayer
|
||||||
|
constructor: (data) ->
|
||||||
|
super(data)
|
||||||
|
@load(data)
|
||||||
|
|
||||||
|
load: (data) ->
|
||||||
|
@ready = false
|
||||||
|
@setMediaProperties(data)
|
||||||
|
|
||||||
|
{ whepURL, streamKey } = data.meta
|
||||||
|
|
||||||
|
waitUntilDefined window, 'PlayerJSPlayer', =>
|
||||||
|
videoEl = document.createElement 'video'
|
||||||
|
videoEl.autoplay = true
|
||||||
|
videoEl.muted = true
|
||||||
|
videoEl.controls = true
|
||||||
|
removeOld(videoEl)
|
||||||
|
@setupPlayer(videoEl, data)
|
||||||
|
|
||||||
|
pc = new RTCPeerConnection()
|
||||||
|
pc.addTransceiver 'audio', direction: 'recvonly'
|
||||||
|
pc.addTransceiver 'video', direction: 'recvonly'
|
||||||
|
|
||||||
|
pc.ontrack = (event) ->
|
||||||
|
videoEl.srcObject = event.streams[0]
|
||||||
|
|
||||||
|
pc.oniceconnectionstatechange = ->
|
||||||
|
document.getElementById('connectionState').innerText = pc.iceConnectionState
|
||||||
|
|
||||||
|
pc.createOffer().then (offer) ->
|
||||||
|
pc.setLocalDescription offer
|
||||||
|
fetch whepURL,
|
||||||
|
method: 'POST'
|
||||||
|
headers:
|
||||||
|
'Authorization': "Bearer #{streamKey}"
|
||||||
|
'Content-Type': 'application/sdp'
|
||||||
|
body: offer.sdp
|
||||||
|
.then (r) -> r.text()
|
||||||
|
.then (answer) ->
|
||||||
|
pc.setRemoteDescription type: 'answer', sdp: answer
|
||||||
|
|
||||||
|
pc.onconnectionstatechange = ->
|
||||||
|
if pc.connectionState is 'connected'
|
||||||
|
@ready = true
|
||||||
|
@fire 'ready'
|
||||||
|
document.getElementById('readyFlag').innerText = 'yes'
|
||||||
|
|
@ -281,6 +281,13 @@ var Getters = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
wp: function (id, callback) {
|
||||||
|
const streemId = new URL(id).pathname.split('/').filter(Boolean)[0];
|
||||||
|
var title = `${streemId}'s WHEP Livestream`;
|
||||||
|
var media = new Media(id, title, "--:--", "wp");
|
||||||
|
callback(false, media);
|
||||||
|
},
|
||||||
|
|
||||||
/* rtmp stream */
|
/* rtmp stream */
|
||||||
rt: function (id, callback) {
|
rt: function (id, callback) {
|
||||||
var title = "Livestream";
|
var title = "Livestream";
|
||||||
|
|
|
||||||
|
|
@ -1347,7 +1347,7 @@ function parseMediaLink(url) {
|
||||||
|
|
||||||
if(data.protocol == 'rtmp:') {
|
if(data.protocol == 'rtmp:') {
|
||||||
return { type: 'rt', id: url };
|
return { type: 'rt', id: url };
|
||||||
}
|
}
|
||||||
if (data.pathname.match(/\.m3u8$/)) {
|
if (data.pathname.match(/\.m3u8$/)) {
|
||||||
return { type: 'hl', id: url };
|
return { type: 'hl', id: url };
|
||||||
}
|
}
|
||||||
|
|
@ -1356,6 +1356,8 @@ function parseMediaLink(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(data.hostname.replace('www.', '')){
|
switch(data.hostname.replace('www.', '')){
|
||||||
|
case 'streem.vereto.net':
|
||||||
|
return { type: 'wp', id: url }
|
||||||
case 'youtube.com':
|
case 'youtube.com':
|
||||||
if(data.pathname == '/watch'){
|
if(data.pathname == '/watch'){
|
||||||
return { type: 'yt', id: data.searchParams.get('v') }
|
return { type: 'yt', id: data.searchParams.get('v') }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue