Skip to content

crossOrigin audio and video#273

Merged
danzen merged 2 commits intoCreateJS:masterfrom
CatLabInteractive:master
Jul 24, 2023
Merged

crossOrigin audio and video#273
danzen merged 2 commits intoCreateJS:masterfrom
CatLabInteractive:master

Conversation

@daedeloth
Copy link
Contributor

Video and audio (= media) should also use the crossOrigin property, as otherwise they could taint canvases and probably other things.

…pect the crossOrigin setting (video's can be used in canvasses)
}

var crossOrigin = this._item.crossOrigin;
if (crossOrigin == true) { crossOrigin = "Anonymous"; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be ===, otherwise it's possible to coerce to true under certain conditions, or is that the intent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it from the ImageLoader:

if (crossOrigin == true) { crossOrigin = "Anonymous"; }

Not sure if there is a reason, I just wanted to make it follow the same logic :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think you are right, it should be === in both places. I'll add it to this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just getting to this late... is there really any way around crossOrigin issues... I have always found them not to work - or has the what you are solving here been the problem all along? Anyway, has this worked out for you guys? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Danzen

Not entirely sure what you mean, crossOrigin on images has always worked for me (note that you need to setup cors headers in your image responses in order to get it to work). This pull request adds the ability to request crossOrigin resources for both audio and video.

Audio is probably not really relevant, as for video: I'm drawing a video on my canvas (frame per frame) through createjs. If my video is not loaded from the same domain or crossOrigin isn't set, it throws security warnings. That's why my PR adds the crossOrigin parameter to all media items.

As for the 'strict equal': I don't really think it matters a lot as I can't imagine anyone setting the crossorigin for these types of things to anything other than 'anonymous'. However, maybe someone has a use-case for this, so changing it to strict equal seems to be the right thing to do. (Setting crossOrigin to 'use-credentials' would evaluate to 'true' and would thus set the html property to 'anonymous' :-))

My build is live at https://client.quizwitz.com/test.html, testMultipleChoiceWithVideoAttachment uses a cross domain video and testMultipleChoiceWithAttachment uses a cross domain image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes - sorry missed this again. I meant, I had never been able to get crossorigin on video to work and reading this again, that is what you are solving. Accepting...

…true, to allow setting it to other values than Anonymous by providing a string.
Copy link
Contributor

@danzen danzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with provided code.

}

var crossOrigin = this._item.crossOrigin;
if (crossOrigin == true) { crossOrigin = "Anonymous"; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes - sorry missed this again. I meant, I had never been able to get crossorigin on video to work and reading this again, that is what you are solving. Accepting...

@danzen danzen merged commit 4938426 into CreateJS:master Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments