Support editing frame from video.
This commit is contained in:
parent
046aec7370
commit
77c13230f1
@ -6,7 +6,7 @@ QR.oekaki =
|
|||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
return unless @file?.isImage
|
return unless @file and (@file.isImage or @file.isVideo)
|
||||||
if @isClone
|
if @isClone
|
||||||
link = $ '.file-oekaki', @file.text
|
link = $ '.file-oekaki', @file.text
|
||||||
else
|
else
|
||||||
@ -22,13 +22,29 @@ QR.oekaki =
|
|||||||
return unless QR.postingIsEnabled
|
return unless QR.postingIsEnabled
|
||||||
QR.quote.call @
|
QR.quote.call @
|
||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
|
{isVideo} = post.file
|
||||||
|
currentTime = post.file.fullImage?.currentTime or 0
|
||||||
CrossOrigin.file post.file.url, (blob) ->
|
CrossOrigin.file post.file.url, (blob) ->
|
||||||
if blob
|
if !blob
|
||||||
|
QR.error "Can't load file."
|
||||||
|
else if isVideo
|
||||||
|
video = $.el 'video'
|
||||||
|
$.on video, 'loadedmetadata', ->
|
||||||
|
$.on video, 'seeked', ->
|
||||||
|
canvas = $.el 'canvas',
|
||||||
|
width: video.videoWidth
|
||||||
|
height: video.videoHeight
|
||||||
|
canvas.getContext('2d').drawImage(video, 0, 0)
|
||||||
|
canvas.toBlob (snapshot) ->
|
||||||
|
snapshot.name = post.file.name.replace(/\.\w+$/, '') + '.png'
|
||||||
|
QR.handleFiles [snapshot]
|
||||||
|
QR.oekaki.edit()
|
||||||
|
video.currentTime = currentTime
|
||||||
|
video.src = URL.createObjectURL blob
|
||||||
|
else
|
||||||
blob.name = post.file.name
|
blob.name = post.file.name
|
||||||
QR.handleFiles [blob]
|
QR.handleFiles [blob]
|
||||||
QR.oekaki.edit()
|
QR.oekaki.edit()
|
||||||
else
|
|
||||||
QR.error "Can't load image."
|
|
||||||
|
|
||||||
setup: ->
|
setup: ->
|
||||||
$.global ->
|
$.global ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user