Skip to content

Commit

Permalink
Check if video source has CORS enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lehecht committed Dec 12, 2024
1 parent 6233512 commit 7715e5e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions resources/assets/js/videos/videoContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default {
swappingLabel: false,
disableJobTracking: false,
supportsJumpByFrame: false,
hasCrossOriginError: false,
};
},
provide() {
Expand Down Expand Up @@ -174,9 +175,6 @@ export default {
hasTooLargeError() {
return this.error instanceof VideoTooLargeError;
},
hasCrossOriginError() {
return this.error instanceof TypeError;
},
errorClass() {
if (this.hasVideoError) {
if (this.error instanceof VideoNotProcessedError) {
Expand Down Expand Up @@ -582,7 +580,19 @@ export default {
.then(this.maybeFocusInitialAnnotation)
.then(this.maybeInitCurrentTime);
this.video.src = this.videoFileUri.replace(':id', video.id);
let self = this;
fetch(this.videoFileUri.replace(':id', video.id))
.then((res) => {
res.blob().then(function (blob) {
let urlCreator = window.URL || window.webkitURL;
self.video.src = urlCreator.createObjectURL(blob);
});
})
.catch((e) => {
// Access on non-CORS enabled file causes TypeError
this.hasCrossOriginError = e instanceof TypeError;
self.video.src = self.videoFileUri.replace(':id', video.id);
});
return promise;
},
Expand Down

0 comments on commit 7715e5e

Please sign in to comment.