Skip to content

Commit

Permalink
feat(cxl-ui): cxl-jw-player refactor base url
Browse files Browse the repository at this point in the history
  • Loading branch information
anoblet committed Sep 23, 2024
1 parent 702065a commit a61f29b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/cxl-ui/src/components/cxl-jw-player/mixins/BaseMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { MediaQueryController } from '@vaadin/component-base/src/media-query-con

export function BaseMixin(BaseClass) {
class Mixin extends BaseClass {
_baseUrl = 'https://cdn.jwplayer.com/';

_boundOnTimeListener;

_chapters;
Expand Down Expand Up @@ -70,7 +72,7 @@ export function BaseMixin(BaseClass) {

if (this.libraryId) {
if (this.isPublic) {
scriptUrl = `https://content.jwplatform.com/libraries/${this.libraryId}.js`;
scriptUrl = `${this._baseUrl}libraries/${this.libraryId}.js`;
} else {
scriptUrl = this.__signedURL(`libraries/${this.libraryId}.js`);
}
Expand Down Expand Up @@ -113,7 +115,7 @@ export function BaseMixin(BaseClass) {

if (this.mediaId) {
if (this.isPublic) {
response = await fetch(`https://cdn.jwplayer.com/v2/media/${this.mediaId}`);
response = await fetch(`${this._baseUrl}v2/media/${this.mediaId}`);
} else {
response = await fetch(await this._signedJWTURL(`/v2/media/${this.mediaId}`));
}
Expand All @@ -133,7 +135,7 @@ export function BaseMixin(BaseClass) {

if (this.playlistId) {
if (this.isPublic) {
response = await fetch(`https://cdn.jwplayer.com/v2/playlists/${this.playlistId}`);
response = await fetch(`${this._baseUrl}v2/playlists/${this.playlistId}`);
} else {
response = await fetch(await this._signedJWTURL(`/v2/playlists/${this.playlistId}`));
}
Expand Down Expand Up @@ -227,7 +229,7 @@ export function BaseMixin(BaseClass) {
const expires = Math.ceil((new Date().getTime() + 3600) / 300) * 300;
const signature = MD5(`${path}:${expires}:${this.apiSecret}`);

return `https://cdn.jwplayer.com/${path}?exp=${expires}&sig=${signature}`;
return `${this._baseUrl}${path}?exp=${expires}&sig=${signature}`;
}
}

Expand Down

0 comments on commit a61f29b

Please sign in to comment.