mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
1 parent
45ec17798f
commit
2fc9d4d3e9
144 files changed
+732
-1472
No files matched your search
@@ -4,21 +4,4 @@
|
||||
* (c) 2017-2023 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!// modules are defined as an array
|
||||
// [ module function, map of requires ]
|
||||
//
|
||||
// map of requires is short require name -> numeric require
|
||||
//
|
||||
// anything defined in a previous bundle is accessed via the
|
||||
// orig method which is the require for previous bundles
|
||||
function(e,t,r,n,o){/* eslint-disable no-undef */var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof i[n]&&i[n],a=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!a[t]){if(!e[t]){// if we cannot find the module within our internal map or
|
||||
// cache jump to the current global require ie. the last bundle
|
||||
// that was added to the page.
|
||||
var o="function"==typeof i[n]&&i[n];if(!r&&o)return o(t,!0);// If there are other bundles on this page the require from the
|
||||
// previous one is saved to 'previousRequire'. Repeat this as
|
||||
// many times as there are bundles until the module is found or
|
||||
// we exhaust the require chain.
|
||||
if(s)return s(t,!0);// Try the node require function if it exists.
|
||||
if(l&&"string"==typeof t)return l(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},p.cache={};var f=a[t]=new u.Module(t);e[t][0].call(f.exports,p,f,f.exports,this)}return a[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=a,u.parent=s,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return i[n]}}),i[n]=u;for(var c=0;c<t.length;c++)u(t[c]);if(r){// Expose entry point to Node, AMD or browser globals
|
||||
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||||
var f=u(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd?define(function(){return f}):o&&(this[o]=f)}}({esZVA:[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",function(){return p});var o=e("@swc/helpers/_/_assert_this_initialized"),i=e("@swc/helpers/_/_class_call_check"),s=e("@swc/helpers/_/_create_class"),a=e("@swc/helpers/_/_inherits"),l=e("@swc/helpers/_/_create_super"),u=e("./emitter"),c=n.interopDefault(u),f=e("./utils"),p=/*#__PURE__*/function(e){(0,a._)(r,e);var t=(0,l._)(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,i._)(this,r),(e=t.call(this)).processing=!1,e.option={},e.setup(Object.assign({},r.DEFAULTS,n)),e.video=r.creatVideo(),e.duration=0,e.inputChange=e.inputChange.bind((0,o._)(e)),e.ondrop=e.ondrop.bind((0,o._)(e)),e.option.fileInput.addEventListener("change",e.inputChange),e.option.fileInput.addEventListener("dragover",r.ondragover),e.option.fileInput.addEventListener("drop",r.ondrop),e}return(0,s._)(r,[{key:"ondrop",value:function(e){e.preventDefault();var t=e.dataTransfer.files[0];this.loadVideo(t)}},{key:"setup",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this;this.option=Object.assign({},this.option,e);var r=this.option,n=r.fileInput,o=r.number,i=r.width,s=r.column;if(this.errorHandle(n instanceof Element,"The 'fileInput' is not a Element"),!("INPUT"===n.tagName&&"file"===n.type)){n.style.position="relative";var a=document.createElement("input");a.type="file",a.style.position="absolute",a.style.width="100%",a.style.height="100%",a.style.left="0",a.style.top="0",a.style.right="0",a.style.bottom="0",a.style.opacity="0",n.appendChild(a),this.option.fileInput=a}return["number","width","column","begin","end"].forEach(function(e){t.errorHandle("number"==typeof t.option[e],"The '".concat(e,"' is not a number"))}),this.option.number=(0,f.clamp)(o,10,1e3),this.option.width=(0,f.clamp)(i,10,1e3),this.option.column=(0,f.clamp)(s,1,1e3),this}},{key:"inputChange",value:function(e){var t=this.option.fileInput.files[0];this.loadVideo(t),e.target.value=""}},{key:"loadVideo",value:function(e){if(e){var t=this.video.canPlayType(e.type);this.errorHandle("maybe"===t||"probably"===t,"Playback of this file format is not supported: ".concat(e.type));var r=URL.createObjectURL(e);this.videoUrl=r,this.file=e,this.emit("file",this.file),this.video.src=r,this.emit("video",this.video)}}},{key:"start",value:function(){var e=this;if(!this.video.duration)return(0,f.sleep)(1e3).then(function(){return e.start()});var t=this.option,r=t.width,n=t.number,o=t.begin,i=t.end,s=this.video.videoHeight/this.video.videoWidth*r;this.option.height=s,this.option.begin=(0,f.clamp)(o,0,this.video.duration),this.option.end=(0,f.clamp)(i||this.video.duration,o,this.video.duration),this.errorHandle(this.option.end>this.option.begin,"End time must be greater than the start time"),this.duration=this.option.end-this.option.begin,this.density=n/this.duration,this.errorHandle(this.file&&this.video,"Please select the video file first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment..."),this.errorHandle(this.density<=1,"The preview density cannot be greater than 1, but got ".concat(this.density));var a=this.creatScreenshotDate(),l=this.creatCanvas(),u=l.getContext("2d");this.emit("canvas",l);var c=a.map(function(t,o){return function(){return new Promise(function(i){e.video.oncanplay=function(){u.drawImage(e.video,t.x,t.y,r,s),l.toBlob(function(t){e.thumbnailUrl&&URL.revokeObjectURL(e.thumbnailUrl),e.thumbnailUrl=URL.createObjectURL(t),e.emit("update",e.thumbnailUrl,(o+1)/n),e.video.oncanplay=null,i()})},e.video.currentTime=t.time})}});return this.processing=!0,(0,f.runPromisesInSeries)(c).then(function(){e.processing=!1,e.emit("done")}).catch(function(t){throw e.processing=!1,e.emit("error",t.message),t})}},{key:"creatScreenshotDate",value:function(){for(var e=this.option,t=e.number,r=e.width,n=e.height,o=e.column,i=e.begin,s=this.duration/t,a=[i+s];a.length<t;){var l=a[a.length-1];a.push(l+s)}return a.map(function(e,t){return{time:e-s/2,x:t%o*r,y:Math.floor(t/o)*n}})}},{key:"creatCanvas",value:function(){var e=this.option,t=e.number,r=e.width,n=e.height,o=e.column,i=document.createElement("canvas"),s=i.getContext("2d");return i.width=r*o,i.height=Math.ceil(t/o)*n+30,s.fillStyle="black",s.fillRect(0,0,i.width,i.height),s.font="14px Georgia",s.fillStyle="#fff",s.fillText("From: https://artplayer.org/, Number: ".concat(t,", Width: ").concat(r,", Height: ").concat(n,", Column: ").concat(o),10,i.height-11),i}},{key:"download",value:function(){this.errorHandle(this.file&&this.thumbnailUrl,"Download does not seem to be ready, please create preview first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment...");var e=document.createElement("a"),tLine truncated
|
||||
!function(e,t,r,n,o){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof s[n]&&s[n],a=i.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,r){if(!a[t]){if(!e[t]){var o="function"==typeof s[n]&&s[n];if(!r&&o)return o(t,!0);if(i)return i(t,!0);if(l&&"string"==typeof t)return l(t);var u=new Error("Cannot find module '"+t+"'");throw u.code="MODULE_NOT_FOUND",u}p.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},p.cache={};var f=a[t]=new c.Module(t);e[t][0].call(f.exports,p,f,f.exports,this)}return a[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.exports={}},c.modules=e,c.cache=a,c.parent=i,c.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(c,"root",{get:function(){return s[n]}}),s[n]=c;for(var u=0;u<t.length;u++)c(t[u]);if(r){var f=c(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd&&define((function(){return f}))}}({esZVA:[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",(function(){return v}));var o=e("@swc/helpers/src/_assert_this_initialized.mjs"),s=n.interopDefault(o),i=e("@swc/helpers/src/_class_call_check.mjs"),a=n.interopDefault(i),l=e("@swc/helpers/src/_create_class.mjs"),c=n.interopDefault(l),u=e("@swc/helpers/src/_inherits.mjs"),f=n.interopDefault(u),p=e("@swc/helpers/src/_create_super.mjs"),h=n.interopDefault(p),d=e("./emitter"),m=n.interopDefault(d),_=e("./utils"),v=function(e){"use strict";(0,f.default)(r,e);var t=(0,h.default)(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,a.default)(this,r),(e=t.call(this)).processing=!1,e.option={},e.setup(Object.assign({},r.DEFAULTS,n)),e.video=r.creatVideo(),e.duration=0,e.inputChange=e.inputChange.bind((0,s.default)(e)),e.ondrop=e.ondrop.bind((0,s.default)(e)),e.option.fileInput.addEventListener("change",e.inputChange),e.option.fileInput.addEventListener("dragover",r.ondragover),e.option.fileInput.addEventListener("drop",r.ondrop),e}return(0,c.default)(r,[{key:"ondrop",value:function(e){e.preventDefault();var t=e.dataTransfer.files[0];this.loadVideo(t)}},{key:"setup",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this;this.option=Object.assign({},this.option,e);var r=this.option,n=r.fileInput,o=r.number,s=r.width,i=r.column;if(this.errorHandle(n instanceof Element,"The 'fileInput' is not a Element"),"INPUT"!==n.tagName||"file"!==n.type){n.style.position="relative";var a=document.createElement("input");a.type="file",a.style.position="absolute",a.style.width="100%",a.style.height="100%",a.style.left="0",a.style.top="0",a.style.right="0",a.style.bottom="0",a.style.opacity="0",n.appendChild(a),this.option.fileInput=a}return["number","width","column","begin","end"].forEach((function(e){t.errorHandle("number"==typeof t.option[e],"The '".concat(e,"' is not a number"))})),this.option.number=(0,_.clamp)(o,10,1e3),this.option.width=(0,_.clamp)(s,10,1e3),this.option.column=(0,_.clamp)(i,1,1e3),this}},{key:"inputChange",value:function(e){var t=this.option.fileInput.files[0];this.loadVideo(t),e.target.value=""}},{key:"loadVideo",value:function(e){if(e){var t=this.video.canPlayType(e.type);this.errorHandle("maybe"===t||"probably"===t,"Playback of this file format is not supported: ".concat(e.type));var r=URL.createObjectURL(e);this.videoUrl=r,this.file=e,this.emit("file",this.file),this.video.src=r,this.emit("video",this.video)}}},{key:"start",value:function(){var e=this;if(!this.video.duration)return(0,_.sleep)(1e3).then((function(){return e.start()}));var t=this.option,r=t.width,n=t.number,o=t.begin,s=t.end,i=this.video.videoHeight/this.video.videoWidth*r;this.option.height=i,this.option.begin=(0,_.clamp)(o,0,this.video.duration),this.option.end=(0,_.clamp)(s||this.video.duration,o,this.video.duration),this.errorHandle(this.option.end>this.option.begin,"End time must be greater than the start time"),this.duration=this.option.end-this.option.begin,this.density=n/this.duration,this.errorHandle(this.file&&this.video,"Please select the video file first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment..."),this.errorHandle(this.density<=1,"The preview density cannot be greater than 1, but got ".concat(this.density));var a=this.creatScreenshotDate(),l=this.creatCanvas(),c=l.getContext("2d");this.emit("canvas",l);var u=a.map((function(t,o){return function(){return new Promise((function(s){e.video.oncanplay=function(){c.drawImage(e.video,t.x,t.y,r,i),l.toBlob((function(t){e.thumbnailUrl&&URL.revokeObjectURL(e.thumbnailUrl),e.thumbnailUrl=URL.createObjectURL(t),e.emit("update",e.thumbnailUrl,(o+1)/n),e.video.oncanplaLine truncated
|
||||
Reference in new issue
Block a user