Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createDashPlayer = (
video: Video,
videoNode: HTMLVideoElement,
): MediaPlayerClass => {
const dash = MediaPlayer().create();
dash.initialize(videoNode, video.urls.manifests.dash, false);
dash.updateSettings({
streaming: {
abr: {
initialBitrate: {
video: 1600, // 480p
},
maxBitrate: {
video: 2400, // 720p
},
},
fastSwitchEnabled: true,
},
} as MediaPlayerSettingClass);
return dash;
})
hls.on(Hls.Events.BUFFER_RESET, () => {
console.log('test')
})
} else if (this.player.canPlayType('application/vnd.apple.mpegurl')) {
source.src = this.options.src[this.currentIndex].src
this.player.addEventListener('canplay', () => {
this.play()
})
}
}
break
case 'dash':
console.log('dash')
if (dashjs) {
const player = dashjs.MediaPlayer().create()
player.initialize(this.player, this.options.src[this.currentIndex].src, true)
}
break
default:
source.src = this.options.src[this.currentIndex].src
source.type = this.options.src[this.currentIndex].type
break
}
}
document.querySelectorAll('span#tourism video').forEach((video, index) => {
if (!video.player) {
video.player = dashPlayer().create();
video.player.getDebug().setLogToBrowserConsole(false);
video.player.initialize(video, VIDEOS[index], false);
video.player.setFastSwitchEnabled(true);
video.player.setInitialRepresentationRatioFor('video', 1);
video.player.on('error', console.error);
}
video.player.seek(0);
this.videos.push(video);
});
}
constructor(
@Host() @Self() @Optional() private _dp: DPlayerComponent
) {
try {
this._instance = MediaPlayer().create();
this._instance.getDebug().setLogToBrowserConsole(false);
this._dp.MSE.push(this.init);
} finally {
}
}
import {MediaPlayer} from 'dashjs';
let url = "https://dash.akamaized.net/envivio/Envivio-dash2/manifest.mpd";
let player = MediaPlayer().create();
player.initialize(document.querySelector('#myMainVideoPlayer'), url, true);
return new Promise((resolve, reject) => {
let mediaPlayer = MediaPlayer().create();
mediaPlayer.initialize();
mediaPlayer.attachView(this.videoElement_);
mediaPlayer.attachSource(this.manifestUrl_);
mediaPlayer.on(MediaPlayer.events.MANIFEST_LOADED, () => {
resolve();
});
mediaPlayer.on(MediaPlayer.events.ERROR, ev => {
reject(`Failed to load Mss Player: ${ev.error.message}`);
});
this.mediaPlayer_ = mediaPlayer;
});
}
load = (url) => {
let hls = new Hls();
if (this.shouldUseHLS(url)) {
hls.loadSource(url);
hls.attachMedia(this.player);
}
if (this.shouldUseDASH(url)) {
const player = dashjs.MediaPlayer().create()
player.getDebug().setLogToBrowserConsole(false)
player.initialize(this.player, url, false)
}
}
shouldUseHLS (url) {