Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
mkioKey: '',
};
},
created() {
this.getMKIOPlayerKey();
async created(): Promise<void> {
await this.getMKIOPlayerKey();
this.load();
this.getDisplayAVFlag();
this.getAudioVideoUnavailableView();
Expand Down Expand Up @@ -173,7 +173,7 @@
videoElement.controls = true;
}
},
async getMKIOPlayerKey() {
async getMKIOPlayerKey(): Promise<void> {
this.mkioKey = await contentData.getMKPlayerKey();
//return this.mkioKey;
},
Expand All @@ -188,11 +188,13 @@
// Grab the video container
this.videoContainer = document.getElementById(this.getPlayerUniqueId);

var licenceKey = this.mkioKey;// this.getMKIOPlayerKey();
if(!this.mkioKey) {
this.getMKIOPlayerKey();
}

// Prepare the player configuration
const playerConfig = {
key: licenceKey,
key: this.mkioKey,
ui: false,
playback: {
muted: false,
Expand Down
5 changes: 3 additions & 2 deletions AdminUI/LearningHub.Nhs.AdminUI/Services/MKIOMediaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ public async Task<BlobDownloadResult> DownloadMediaInputAsset(string inputAssetN
/// <returns>The <see cref="string"/>.</returns>
public async Task<string> GetContentAuthenticationTokenAsync(string encodedAssetId)
{
byte[] tokenSigningKey = Convert.FromBase64String(this.settings.AzureMediaJWTPrimaryKeySecret);
byte[] tokenSigningKey = Convert.FromBase64String(this.settings.MediaKindSettings.JWTPrimaryKeySecret);

var keyidentifier = string.Empty; // await this.GetContentKeyIdentifier(encodedAssetId);
int expiryMinutes = 0; // this.settings.AzureMediaJWTTokenExpiryMinutes;

return GetJWTToken(this.settings.AzureMediaIssuer, this.settings.AzureMediaAudience, keyidentifier, tokenSigningKey, this.settings.AzureMediaJWTTokenExpiryMinutes);
return GetJWTToken(this.settings.MediaKindSettings.Issuer, this.settings.MediaKindSettings.Audience, keyidentifier, tokenSigningKey, expiryMinutes);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import { FileModel } from '../../models/contribute-resource/files/fileModel';
import { VideoFileModel } from '../../models/contribute-resource/blocks/videoFileModel';
import { MKPlayer } from '@mediakind/mkplayer';
import { resourceData } from '../../data/resource';
export default Vue.extend({
props: {
fileId: Number,
Expand All @@ -47,65 +48,11 @@
sourceLoaded: true,
};
},
created() {
this.getMKIOPlayerKey();
async created() {
await this.getMKIOPlayerKey();
this.getMediaPlayUrl();
},
mounted() {
// Grab the video container
this.videoContainer = document.getElementById(this.getPlayerUniqueId);

// Prepare the player configuration
const playerConfig = {
key: this.mkioKey,
ui: false,
theme: "dark",
playback: {
muted: false,
autoplay: false,
},
events: {
//error: this.onPlayerError,
//timechanged: this.onTimeChanged,
//onpause: this.onpause,
//onplay: this.onplay,
//muted: this.onMuted,
//unmuted: this.onUnmuted,
ready: this.onPlayerReady,
subtitleadded: this.onSubtitleAdded,

//playbackspeed: this.onPlaybackSpeed
}
};

// Initialize the player with video container and player configuration
this.player = new MKPlayer(this.videoContainer, playerConfig);

// ClearKey DRM configuration
var clearKeyConfig = {
//LA_URL: "https://ottapp-appgw-amp.prodc.mkio.tv3cloud.com/drm/clear-key?ownerUid=azuki",
LA_URL:"HLS_AES",
headers: {
"Authorization": this.getBearerToken()
}
};

// Load source
const sourceConfig = {
hls: this.playBackUrl,
drm: {
clearkey: clearKeyConfig
}
};

this.player.load(sourceConfig)
.then(() => {
console.log("Source loaded successfully!");
})
.catch(() => {
console.error("An error occurred while loading the source!");
});
},
this.load();
},
methods: {
onPlayerReady() {
const videoElement = document.getElementById("bitmovinplayer-video-" + this.getPlayerUniqueId) as HTMLVideoElement;
Expand All @@ -130,8 +77,8 @@
onSubtitleAdded() {

},
getMKIOPlayerKey() {
this.mkioKey = this.$store.state.getMKPlayerLicenceKey;
async getMKIOPlayerKey(): Promise<void> {
this.mkioKey = await resourceData.getMKPlayerKey();
},
getBearerToken() {
return "Bearer=" + this.azureMediaServicesToken;
Expand All @@ -141,6 +88,65 @@
this.playBackUrl = this.playBackUrl.substring(0, this.playBackUrl.lastIndexOf("manifest")) + "manifest(format=m3u8-cmaf,encryption=cbc)";
// this.playBackUrl = "https://ep-defaultlhdev-mediakind02-dev-by-am-sl.uksouth.streaming.mediakind.com/d01d30e4-461f-4045-bc10-3c88a296f3af/manifest.ism/manifest(format=m3u8-cmaf,encryption=cbc)"
},
load() {
// Grab the video container
this.videoContainer = document.getElementById(this.getPlayerUniqueId);

if(!this.mkioKey) {
this.getMKIOPlayerKey();
}

// Prepare the player configuration
const playerConfig = {
key: this.mkioKey,
ui: false,
theme: "dark",
playback: {
muted: false,
autoplay: false,
},
events: {
//error: this.onPlayerError,
//timechanged: this.onTimeChanged,
//onpause: this.onpause,
//onplay: this.onplay,
//muted: this.onMuted,
//unmuted: this.onUnmuted,
ready: this.onPlayerReady,
subtitleadded: this.onSubtitleAdded,

//playbackspeed: this.onPlaybackSpeed
}
};

// Initialize the player with video container and player configuration
this.player = new MKPlayer(this.videoContainer, playerConfig);

// ClearKey DRM configuration
var clearKeyConfig = {
//LA_URL: "https://ottapp-appgw-amp.prodc.mkio.tv3cloud.com/drm/clear-key?ownerUid=azuki",
LA_URL:"HLS_AES",
headers: {
"Authorization": this.getBearerToken()
}
};

// Load source
const sourceConfig = {
hls: this.playBackUrl,
drm: {
clearkey: clearKeyConfig
}
};

this.player.load(sourceConfig)
.then(() => {
console.log("Source loaded successfully!");
})
.catch(() => {
console.error("An error occurred while loading the source!");
});
}
},
computed: {
getPlayerUniqueId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,15 @@
await this.getGeneralUser();
await this.getUserRole();
await this.loadResourceItem(Number(this.$route.params.resId));
await this.getMKIOPlayerKey();
await this.getMediaPlayUrl();
await this.setupMKPlayer();

if (this.userAuthenticated && this.resourceItem.catalogue.restrictedAccess) {
await this.loadRoleUserGroups();
}


if (this.userAuthenticated && (this.resourceItem.resourceTypeEnum == ResourceType.VIDEO || this.resourceItem.resourceTypeEnum == ResourceType.AUDIO) && this.hasResourceAccess()) {
await this.getMKIOPlayerKey();
await this.getMediaPlayUrl();
await this.setupMKPlayer();
this.addMediaEventListeners();
//this.checkForAutoplay();
}
Expand Down Expand Up @@ -372,7 +371,6 @@
this.playBackDashUrl = this.resourceItem.videoDetails.resourceAzureMediaAsset.locatorUri;
}
this.playBackUrl = this.playBackUrl.substring(0, this.playBackUrl.lastIndexOf("manifest")) + "manifest(format=m3u8-cmaf,encryption=cbc)";
// this.playBackUrl = "https://ep-defaultlhdev-mediakind02-dev-by-am-sl.uksouth.streaming.mediakind.com" + this.playBackUrl;
},
getMediaAssetProxyUrl(playBackUrl: string): string {
playBackUrl = playBackUrl.substring(0, playBackUrl.lastIndexOf("manifest")) + "manifest(format=mpd-time-cmaf,encryption=cenc)";
Expand Down
5 changes: 3 additions & 2 deletions LearningHub.Nhs.WebUI/Services/MKIOMediaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ public async Task<string> CreateMediaInputAsset(IFormFile file)
/// <returns>The <see cref="T:Task{string}"/>.</returns>
public async Task<string> GetContentAuthenticationTokenAsync(string encodedAssetId)
{
byte[] tokenSigningKey = Convert.FromBase64String(this.settings.AzureMediaJWTPrimaryKeySecret);
byte[] tokenSigningKey = Convert.FromBase64String(this.settings.MediaKindSettings.JWTPrimaryKeySecret);

var keyidentifier = string.Empty; // await this.GetContentKeyIdentifier(encodedAssetId);
int expiryMinutes = 0; // this.settings.AzureMediaJWTTokenExpiryMinutes;

return GetJWTToken(this.settings.AzureMediaIssuer, this.settings.AzureMediaAudience, keyidentifier, tokenSigningKey, this.settings.AzureMediaJWTTokenExpiryMinutes);
return GetJWTToken(this.settings.MediaKindSettings.Issuer, this.settings.MediaKindSettings.Audience, keyidentifier, tokenSigningKey, expiryMinutes);
}

/// <summary>
Expand Down