|
1 | 1 | <link href="~/css/mkplayer-ui.css" rel="stylesheet" asp-append-version="true" /> |
2 | 2 | <template> |
3 | 3 | <div> |
4 | | - <div :id="getPlayerUniqueId" class="video-container"></div> |
| 4 | + <div :id="playerUniqueId" class="video-container"></div> |
5 | 5 | <noscript> |
6 | 6 | <p class="amp-no-js"> |
7 | 7 | To view this media please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video |
|
50 | 50 | mkioKey: '', |
51 | 51 | playBackUrl: '', |
52 | 52 | sourceLoaded: true, |
53 | | - isIphone: false |
| 53 | + isIphone: false, |
| 54 | + playerUniqueId: `videoContainer_${this.fileId}_${Date.now()}` // We need to generate a new unique ID for the video player on every render otherwise the video player will not load properly. |
54 | 55 | }; |
55 | 56 | }, |
56 | | - async created() { |
| 57 | + async mounted() { |
| 58 | + this.checkIfIphone(); |
| 59 | +
|
57 | 60 | await this.getMKIOPlayerKey(); |
| 61 | +
|
58 | 62 | this.getMediaPlayUrl(); |
59 | | - this.load(); |
60 | | - }, |
61 | | - mounted() { |
62 | | - this.checkIfIphone(); |
| 63 | +
|
| 64 | + this.$nextTick(() => { |
| 65 | + this.load(); |
| 66 | + }); |
63 | 67 | }, |
64 | 68 | methods: { |
65 | 69 | onPlayerReady() { |
|
96 | 100 | return "Bearer=" + this.azureMediaServicesToken; |
97 | 101 | }, |
98 | 102 | getMediaPlayUrl() { |
| 103 | + console.log(this.videoFile.locatorUri); |
99 | 104 | this.playBackUrl = this.videoFile.locatorUri; |
100 | 105 | this.playBackUrl = this.playBackUrl.substring(0, this.playBackUrl.lastIndexOf("manifest")) + "manifest(format=m3u8-cmaf,encryption=cbc)"; |
101 | 106 | if (this.isIphone) { |
102 | 107 | this.playBackUrl = "/Media/MediaManifest?playBackUrl=" + this.playBackUrl + "&token=" + this.azureMediaServicesToken; |
103 | | - } |
| 108 | + } |
104 | 109 | }, |
105 | 110 | checkIfIphone() { |
106 | 111 | const userAgent = navigator.userAgent || navigator.vendor; |
107 | 112 | this.isIphone = /iPhone/i.test(userAgent); |
108 | 113 | }, |
109 | 114 | load() { |
110 | 115 | // Grab the video container |
111 | | - this.videoContainer = document.getElementById(this.getPlayerUniqueId); |
112 | | -
|
113 | | - if (!this.mkioKey) { |
114 | | - this.getMKIOPlayerKey(); |
115 | | - } |
| 116 | + this.videoContainer = document.getElementById(this.playerUniqueId); |
116 | 117 |
|
117 | 118 | // Prepare the player configuration |
118 | 119 | const playerConfig = { |
|
168 | 169 | } |
169 | 170 | }, |
170 | 171 | computed: { |
171 | | - getPlayerUniqueId(): string { |
172 | | - // We need to generate a new unique ID for the video player on every render otherwise the video player will not load properly. |
173 | | - // This is because the AMP is only intended to be a static player and so is not optimised for componentisation. |
174 | | - // So, when we switch between tabs on the Case resource creation page, the video player unmounts and then remounts if |
175 | | - // we go back to the Contents tab. As a result, a new unique ID is needed so that the media player knows it has to |
176 | | - // initalise itself again, which we do in the `mounted()` lifecycle method above. |
177 | | - const time = new Date().getTime() |
178 | | - return `videoContainer_${this.fileId}_${time}` |
179 | | - }, |
| 172 | + //getPlayerUniqueId(): string { |
| 173 | + // // We need to generate a new unique ID for the video player on every render otherwise the video player will not load properly. |
| 174 | + // // This is because the AMP is only intended to be a static player and so is not optimised for componentisation. |
| 175 | + // // So, when we switch between tabs on the Case resource creation page, the video player unmounts and then remounts if |
| 176 | + // // we go back to the Contents tab. As a result, a new unique ID is needed so that the media player knows it has to |
| 177 | + // // initalise itself again, which we do in the `mounted()` lifecycle method above. |
| 178 | + // const time = new Date().getTime() |
| 179 | + // console.log("getPlayerUniqueId " + this.fileId); |
| 180 | + // return `videoContainer_${this.fileId}_${time}` |
| 181 | + //}, |
180 | 182 | captionsTrackAvailable(): boolean { |
181 | 183 | return !!this.videoFile |
182 | 184 | && !!this.videoFile.captionsFile |
|
200 | 202 | return this.transcriptFileModel.getDownloadResourceLink(); |
201 | 203 | }, |
202 | 204 | }, |
| 205 | + watch: { |
| 206 | + videoFile: { |
| 207 | + immediate: true, |
| 208 | + handler() { |
| 209 | + if (this.player) { |
| 210 | + this.player.destroy(); |
| 211 | + } |
| 212 | +
|
| 213 | + this.getMediaPlayUrl(); |
| 214 | +
|
| 215 | + this.$nextTick(() => { |
| 216 | + this.load(); |
| 217 | + }); |
| 218 | + } |
| 219 | + } |
| 220 | + } |
203 | 221 | }) |
204 | 222 | </script> |
205 | 223 |
|
|
232 | 250 | --min-width: 200px; |
233 | 251 | } |
234 | 252 | } |
| 253 | +
|
235 | 254 | @media (min-width: 375px) { /* Non standard for graceful */ |
236 | 255 | .video-container { |
237 | 256 | --min-width: 300px; |
238 | 257 | } |
239 | 258 | } |
| 259 | +
|
240 | 260 | @media (min-width: 450px) { /* Non standard for graceful */ |
241 | 261 | .video-container { |
242 | 262 | --min-width: 400px; |
243 | 263 | } |
244 | 264 | } |
| 265 | +
|
245 | 266 | @media (min-width: 576px) { |
246 | 267 | .video-container { |
247 | 268 | --min-width: 500px; |
248 | 269 | } |
249 | 270 | } |
| 271 | +
|
250 | 272 | @media (min-width: 650px) { /* Non standard for graceful */ |
251 | 273 | .video-container { |
252 | 274 | --min-width: 600px; |
253 | 275 | } |
254 | 276 | } |
| 277 | +
|
255 | 278 | @media (min-width: 768px) { |
256 | 279 | .video-container { |
257 | 280 | --min-width: 700px; |
258 | 281 | } |
259 | 282 | } |
| 283 | +
|
260 | 284 | @media (min-width: 850px) { /* Non standard for graceful */ |
261 | 285 | .video-container { |
262 | 286 | --min-width: 800px; |
263 | 287 | } |
264 | 288 | } |
265 | | - @media (min-width: 992px) { |
| 289 | +
|
| 290 | + @media (min-width: 992px) { |
266 | 291 | .video-container { |
267 | 292 | --min-width: 900px; |
268 | 293 | } |
269 | | - } |
| 294 | + } |
| 295 | +
|
270 | 296 | @media (min-width: 1024px) { |
271 | 297 | .video-container { |
272 | 298 | --min-width: 1024px; |
|
0 commit comments