Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
super(options)
let self = this
this.shakaOpts = options.shakaOpts || {}
this.util = Player.util
this.player = this
this.url = this.player.config.url
this.sniffer = Player.sniffer
this.player_ = null
this.content = []
Shaka.polyfill.installAll()
if (Shaka.Player.isBrowserSupported()) {
this.video_ = this.player.video
this.video_.autoplay = false
this.player_ = new Shaka.Player(this.video_)
this.player_.addEventListener('error', function (event) {
console.error('Error code', event.detail.code, 'object', event.detail) // eslint-disable-line no-console
})
if (this.shakaOpts) {
this.player_.configure(this.shakaOpts)
}
this.player_.getNetworkingEngine().registerRequestFilter(function (type, request) {
// Only add headers to license requests:
if (type === Shaka.net.NetworkingEngine.RequestType.LICENSE) {
// This is the specific header name and value the server wants:
request.headers['CWIP-Auth-Header'] = 'VGhpc0lzQVRlc3QK'
}
})
initPlayer = () => {
// Create a Player instance with videoNode.
const player = new shaka.Player(this.videoNode);
// Listen for error events.
player.addEventListener('error', this.onErrorEvent);
// Try to load a manifest.
// This is an asynchronous process.
player
.load(this.props.manifestUri)
.then(function () {
// This runs if the asynchronous load is successful.
console.log('The video has now been loaded!');
})
.catch(this.onError); // onError is executed if the asynchronous load fails.
// Configuration for the player here
// https://shaka-player-demo.appspot.com/docs/api/tutorial-config.html
constructor (options) {
super(options)
let self = this
this.shakaOpts = options.shakaOpts || {}
this.util = Player.util
this.player = this
this.url = this.player.config.url
this.sniffer = Player.sniffer
this.player_ = null
this.content = []
Shaka.polyfill.installAll()
if (Shaka.Player.isBrowserSupported()) {
this.video_ = this.player.video
this.video_.autoplay = false
this.player_ = new Shaka.Player(this.video_)
this.player_.addEventListener('error', function (event) {
console.error('Error code', event.detail.code, 'object', event.detail) // eslint-disable-line no-console
})
if (this.shakaOpts) {
this.player_.configure(this.shakaOpts)
}
this.player_.getNetworkingEngine().registerRequestFilter(function (type, request) {
// Only add headers to license requests:
AdaptivePlayer.prototype.loadShakaVideo_ = function(url) {
// Install built-in polyfills to patch browser incompatibilities.
shaka.polyfill.installAll();
if (!shaka.Player.isBrowserSupported()) {
console.error('Shaka is not supported on this browser.');
return;
}
this.initShaka_();
return this.player.load(url);
};
componentDidMount() {
// Install built-in polyfills to patch browser incompatibilities.
shaka.polyfill.installAll();
// Check to see if the browser supports the basic APIs Shaka needs.
if (shaka.Player.isBrowserSupported()) {
// Everything looks good!
this.initPlayer();
} else {
// This browser does not have the minimum set of APIs we need.
console.error('Browser not supported!');
}
}
componentDidMount () {
// Install built-in polyfills to patch browser incompatibilities.
shaka.polyfill.installAll();
// Check to see if the browser supports the basic APIs Shaka needs.
if (shaka.Player.isBrowserSupported()) {
// Everything looks good!
this.initPlayer();
} else {
// This browser does not have the minimum set of APIs we need.
console.error('Browser not supported!');
}
}
this.player_.getNetworkingEngine().registerRequestFilter(function (type, request) {
// Only add headers to license requests:
if (type === Shaka.net.NetworkingEngine.RequestType.LICENSE) {
// This is the specific header name and value the server wants:
request.headers['CWIP-Auth-Header'] = 'VGhpc0lzQVRlc3QK'
}
})
public async load() {
await super.load();
const mediaElement: HTMLMediaElement = (this.instance.getModule(
'HTML5Player',
) as any).mediaElement;
this.player = new shaka.Player(mediaElement);
this.player.addEventListener('error', this.onErrorEvent.bind(this));
this.player.addEventListener(
'adaptation',
this.onAdaptationEvent.bind(this),
);
this.emit(Events.SHAKA_INSTANCE, {
shaka,
player: this.player,
} as IShakaInstEventData);
const configuration: any = {
abr: {
enabled: true,
defaultBandwidthEstimate:
static canPlay (resource, mimeType = '') {
shaka.polyfill.installAll()
let browserSupported = shaka.Player.isBrowserSupported()
let resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || []
return browserSupported && ((resourceParts[1] === 'mpd') || mimeType.indexOf('application/dash+xml') > -1)
}
DashShakaPlayback.canPlay = (resource, mimeType = '') => {
shaka.polyfill.installAll()
var browserSupported = shaka.Player.isBrowserSupported()
var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || []
return browserSupported && (('mpd' === resourceParts[1]) || mimeType.indexOf('application/dash+xml') > -1)
}