|
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() { |
|
100 | 104 | this.playBackUrl = this.playBackUrl.substring(0, this.playBackUrl.lastIndexOf("manifest")) + "manifest(format=m3u8-cmaf,encryption=cbc)"; |
101 | 105 | if (this.isIphone) { |
102 | 106 | this.playBackUrl = "/Media/MediaManifest?playBackUrl=" + this.playBackUrl + "&token=" + this.azureMediaServicesToken; |
103 | | - } |
| 107 | + } |
104 | 108 | }, |
105 | 109 | checkIfIphone() { |
106 | 110 | const userAgent = navigator.userAgent || navigator.vendor; |
107 | 111 | this.isIphone = /iPhone/i.test(userAgent); |
108 | 112 | }, |
109 | 113 | load() { |
110 | 114 | // Grab the video container |
111 | | - this.videoContainer = document.getElementById(this.getPlayerUniqueId); |
112 | | -
|
113 | | - if (!this.mkioKey) { |
114 | | - this.getMKIOPlayerKey(); |
115 | | - } |
| 115 | + this.videoContainer = document.getElementById(this.playerUniqueId); |
116 | 116 |
|
117 | 117 | // Prepare the player configuration |
118 | 118 | const playerConfig = { |
|
168 | 168 | } |
169 | 169 | }, |
170 | 170 | 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 | | - }, |
| 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 | + // console.log("getPlayerUniqueId " + this.fileId); |
| 179 | + // return `videoContainer_${this.fileId}_${time}` |
| 180 | + //}, |
180 | 181 | captionsTrackAvailable(): boolean { |
181 | 182 | return !!this.videoFile |
182 | 183 | && !!this.videoFile.captionsFile |
|
200 | 201 | return this.transcriptFileModel.getDownloadResourceLink(); |
201 | 202 | }, |
202 | 203 | }, |
| 204 | + watch: { |
| 205 | + videoFile: { |
| 206 | + immediate: true, |
| 207 | + handler() { |
| 208 | + if (this.player) { |
| 209 | + this.player.destroy(); |
| 210 | + } |
| 211 | +
|
| 212 | + this.getMediaPlayUrl(); |
| 213 | +
|
| 214 | + this.$nextTick(() => { |
| 215 | + this.load(); |
| 216 | + }); |
| 217 | + } |
| 218 | + } |
| 219 | + } |
203 | 220 | }) |
204 | 221 | </script> |
205 | 222 |
|
|
232 | 249 | --min-width: 200px; |
233 | 250 | } |
234 | 251 | } |
| 252 | +
|
235 | 253 | @media (min-width: 375px) { /* Non standard for graceful */ |
236 | 254 | .video-container { |
237 | 255 | --min-width: 300px; |
238 | 256 | } |
239 | 257 | } |
| 258 | +
|
240 | 259 | @media (min-width: 450px) { /* Non standard for graceful */ |
241 | 260 | .video-container { |
242 | 261 | --min-width: 400px; |
243 | 262 | } |
244 | 263 | } |
| 264 | +
|
245 | 265 | @media (min-width: 576px) { |
246 | 266 | .video-container { |
247 | 267 | --min-width: 500px; |
248 | 268 | } |
249 | 269 | } |
| 270 | +
|
250 | 271 | @media (min-width: 650px) { /* Non standard for graceful */ |
251 | 272 | .video-container { |
252 | 273 | --min-width: 600px; |
253 | 274 | } |
254 | 275 | } |
| 276 | +
|
255 | 277 | @media (min-width: 768px) { |
256 | 278 | .video-container { |
257 | 279 | --min-width: 700px; |
258 | 280 | } |
259 | 281 | } |
| 282 | +
|
260 | 283 | @media (min-width: 850px) { /* Non standard for graceful */ |
261 | 284 | .video-container { |
262 | 285 | --min-width: 800px; |
263 | 286 | } |
264 | 287 | } |
265 | | - @media (min-width: 992px) { |
| 288 | +
|
| 289 | + @media (min-width: 992px) { |
266 | 290 | .video-container { |
267 | 291 | --min-width: 900px; |
268 | 292 | } |
269 | | - } |
| 293 | + } |
| 294 | +
|
270 | 295 | @media (min-width: 1024px) { |
271 | 296 | .video-container { |
272 | 297 | --min-width: 1024px; |
|
0 commit comments