Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dataURL strings to be added directly #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions whammy.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,17 @@ window.Whammy = (function(){
WhammyVideo.prototype.add = function(frame, duration){
if(typeof duration != 'undefined' && this.duration) throw "you can't pass a duration if the fps is set";
if(typeof duration == 'undefined' && !this.duration) throw "if you don't have the fps set, you ned to have durations here."
if('canvas' in frame){ //CanvasRenderingContext2D
frame = frame.canvas;

if(typeof frame == 'object') {
if('canvas' in frame){ //CanvasRenderingContext2D
frame = frame.canvas;
}
if('toDataURL' in frame){
frame = frame.toDataURL('image/webp', this.quality)
}
}
if('toDataURL' in frame){
frame = frame.toDataURL('image/webp', this.quality)
}else if(typeof frame != "string"){

if(typeof frame != "string"){
throw "frame must be a a HTMLCanvasElement, a CanvasRenderingContext2D or a DataURI formatted string"
}
if (!(/^data:image\/webp;base64,/ig).test(frame)) {
Expand Down