Skip to content

Instantly share code, notes, and snippets.

@elv-peter
Created December 11, 2024 06:54
Show Gist options
  • Save elv-peter/b6919abde997ac3748163016d8c07a0d to your computer and use it in GitHub Desktop.
Save elv-peter/b6919abde997ac3748163016d8c07a0d to your computer and use it in GitHub Desktop.
// const url = 'https://dash.akamaized.net/envivio/EnvivioDash3/manifest.mpd'
const url = 'https://host-76-74-91-8.contentfabric.io/qlibs/ilib3C82jGbT41QLSZb35dDwmUWbSuP9/q/hq__CcdV4wnCNq9wv6jXpYeCQ2GE4FLQBFtVSSSt2XKfBJMrH89DFDGsfkpWWvBy16QBGGYeF5mLGo/rep/playout/default/dash-clear/dash.mpd?authorization=ascsj_bFTSWVS9dUhsCBGa96XhfUwrJKzZcJiXN1C5ZfFtpzGbf4HxJtsvMwuWAnbUkM2wNKh1mdMoyTZPqBjAUbyzCMbWHtq3Lq7o8dEUmK3hLnRbBj24oiTD1jdu7rTUVumPCeNNqUyAXmXemv1Kb7VioDfdwW624dUUEpvFcc4MXT7uGy1a1y7VzetBdAYazWbVF6yhWDwnvaNKYkq1We2tyNdmabhuoRyKgPbNJm8EJJg6YiyJSQLwCGRMH88iCZaM6wqX21uVEryWH5BGABNfnRkBRDQxhorbBQT1G1pT6J3VgZdPKLwb9gMLrWzMwxMQupqbDsAi8ojsoWur32XhX7Uekdj9ZFUpGTJnRwePEvN9Wm3EzHrVmGGaH6xqDWSDmpkziw7N8zNWNidxxSbonUuzaPraKfzqjUXm1PpfbansTg5zbhLdXBKht7cq3QqDY14n4BQ3UpXXXpVUddN7H9gmjevxTifM1RMcGXKDhTvjwEWTaPfW3FWXhAGzimCHN9YKLzeWRQ8E7KJkkkp1XHEQVDJNM7AMHZhZwqsrBdk5jdj4cvibvEJN2jrUxjP8wxsnBi7dSoRMuJzAsdPR8NuGgM6Wub7z54gSQxSModvJkoiUtsBpHdJQEiohNYL9Riv64sRRFcXhttFZ8ekXsQXN2EvKYB2ugSihcZSfRrGCm1pQV6vhTmCseGE34WZBsqgFU9TwnzY3T1ZpUxP7mBM6TQa8KDisnUY5fhM2jmKueWkA8TZkvY6RF8b2YQjD68aPMj85HyzaUF5tdMysCacPYJXE8prAR1fTfjNWKQ2c1cQVn9zttx5apsXXQmi1pt1KfBLXA7ZxQXkwB2xywM8N6H9tErSNqPHUmXDrWJsmCx7T1fJEKviQuv3rJHvducSohZwcuJa5Yo9ma47Fnt1hA6wTVuzxEVBaXmpkKFtrj8hoBR7oYHMekdbzXvjyCh6N4TUWgjWH19P8tzpgscpkbwdHspYmGN54BzHJixexyhtXYHmqos3T5x9Lb1sdYUzgpP3TvqVf5qbb1ZcHBJg9652RCTZNjwFTBJ8NKFEcNcqC3UbTpZNCKrmHyKYA5QFaVGRYPVFARQDc6NDi62X6ifSX66mh2CGVH3617M7ceVGc5uhJr3B4GQN8jjVBFiD5At.RVMyNTZLX1R0YWVkbVRUa2FBakxHeDlYYXBKa3lEY0xGUUhxQ1ozTFdWR2lURkhyYm1lTGJMOVlRbWpnblkzU3gyMnhLeXBVeTFlOUNic0dpNzl2b0Z3SkhTd0tIeE4%3D'
async function onLoad() {
let player = dashjs.MediaPlayer().create()
player.initialize(document.getElementById('video'), url, true)
// const protData = {
// "com.widevine.alpha": {
// "serverURL": licenseUrl,
// }
// };
// player.setProtectionData(protData)
}
document.addEventListener('DOMContentLoaded', onLoad)
////////////////////////////////////////
//
// Google Cast management
//
////////////////////////////////////////
window['__onGCastApiAvailable'] = function(isAvailable) {
if (!isAvailable) {
return
}
let context = cast.framework.CastContext.getInstance()
context.setOptions({
receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
})
context.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED, function(e) {
console.log('[Cast]', e)
if (e.castState === cast.framework.CastState.CONNECTED) {
onCastReady()
} else if (e.castState === cast.framework.CastState.NOT_CONNECTED) {
onCastEnd()
}
})
let remotePlayer = new cast.framework.RemotePlayer()
let remotePlayerController = new cast.framework.RemotePlayerController(remotePlayer)
remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED, function(e) {
console.log('[Remote]', e)
})
}
function onCastReady() {
let mediaInfo = new chrome.cast.media.MediaInfo(url, 'application/dash+xml')
let request = new chrome.cast.media.LoadRequest(mediaInfo)
let session = cast.framework.CastContext.getInstance().getCurrentSession()
session.loadMedia(request).then(
function() {
console.info('Cast successful')
},
function(errorCode) {
console.log('Cast error', errorCode)
},
)
}
function onCastEnd() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment