mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 09:41:20 -08:00
完成截图工具例子
This commit is contained in:
1 parent
17dc3af41f
commit
7fc370b6d9
4 files changed
+63
-15
No files matched your search
@@ -60,7 +60,9 @@
|
|||||||
thumbnail.on('video', function(video) {
|
thumbnail.on('video', function(video) {
|
||||||
console.log('Video size: ' + video.videoWidth + ' x ' + video.videoHeight);
|
console.log('Video size: ' + video.videoWidth + ' x ' + video.videoHeight);
|
||||||
console.log('Video duration: ' + video.duration + 's');
|
console.log('Video duration: ' + video.duration + 's');
|
||||||
thumbnail.setup(getConfig()).start();
|
thumbnail.setup(getConfig()).start().then(() => {
|
||||||
|
thumbnail.download();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('canvas', function(canvas) {
|
thumbnail.on('canvas', function(canvas) {
|
||||||
|
|||||||
@@ -303,7 +303,7 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
runPromisesInSeries(promiseList).then(function () {
|
return runPromisesInSeries(promiseList).then(function () {
|
||||||
return sleep(delay * 2).then(function () {
|
return sleep(delay * 2).then(function () {
|
||||||
_this4.processing = false;
|
_this4.processing = false;
|
||||||
|
|
||||||
@@ -380,6 +380,7 @@
|
|||||||
elink.click();
|
elink.click();
|
||||||
document.body.removeChild(elink);
|
document.body.removeChild(elink);
|
||||||
this.emit('download', name);
|
this.emit('download', name);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: "errorHandle",
|
key: "errorHandle",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# artplayer-tool-thumbnail
|
# artplayer-tool-thumbnail
|
||||||
|
|
||||||
thumbnail tool for ArtPlayer
|
thumbnail tool for ArtPlayer
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
@@ -34,7 +35,7 @@ Will expose the global variable to `window.ArtplayerToolThumbnail`.
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<input class="file" type="file">
|
<input class="file" type="file" />
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -47,29 +48,72 @@ var thumbnail = new ArtplayerToolThumbnail({
|
|||||||
column: 10,
|
column: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Dynamic configuration parameters, return the instance itself
|
||||||
|
thumbnail.setup({
|
||||||
|
delay: 500,
|
||||||
|
number: 100,
|
||||||
|
width: 200,
|
||||||
|
height: 10,
|
||||||
|
column: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start creating a preview, return the promise when the task completed
|
||||||
|
thumbnail.start();
|
||||||
|
|
||||||
|
// Start download preview, return the instance itself
|
||||||
|
thumbnail.download();
|
||||||
|
|
||||||
|
// Events
|
||||||
thumbnail.on('file', file => {
|
thumbnail.on('file', file => {
|
||||||
console.log(file);
|
console.log('The video file has been read successfully');
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('video', video => {
|
thumbnail.on('video', video => {
|
||||||
console.log(video);
|
console.log('Building a video player successfully');
|
||||||
thumbnail.start();
|
console.log('Now you can call the thumbnail.start()');
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('canvas', canvas => {
|
thumbnail.on('canvas', canvas => {
|
||||||
console.log(canvas);
|
console.log('Building a canvas successfully');
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('update', (percentage, url) => {
|
thumbnail.on('update', (url, percentage) => {
|
||||||
console.log(percentage, url);
|
console.log('Generating preview image, returning preview url and percentage');
|
||||||
});
|
|
||||||
|
|
||||||
thumbnail.on('download', name => {
|
|
||||||
console.log(name);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('done', () => {
|
thumbnail.on('done', () => {
|
||||||
console.log('done');
|
console.log('One task processing completed');
|
||||||
|
});
|
||||||
|
|
||||||
|
thumbnail.on('download', name => {
|
||||||
|
console.log('Download the preview');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```html
|
||||||
|
<input class="file" type="file" />
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
var thumbnail = new ArtplayerToolThumbnail({
|
||||||
|
fileInput: document.querySelector('.file'),
|
||||||
|
});
|
||||||
|
|
||||||
|
thumbnail.on('video', () => {
|
||||||
|
thumbnail
|
||||||
|
.setup({
|
||||||
|
delay: 500,
|
||||||
|
number: 100,
|
||||||
|
width: 200,
|
||||||
|
height: 10,
|
||||||
|
column: 10,
|
||||||
|
})
|
||||||
|
.start()
|
||||||
|
.then(() => {
|
||||||
|
thumbnail.download();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class ArtplayerToolThumbnail extends Emitter {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
runPromisesInSeries(promiseList)
|
return runPromisesInSeries(promiseList)
|
||||||
.then(() =>
|
.then(() =>
|
||||||
sleep(delay * 2)
|
sleep(delay * 2)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -175,6 +175,7 @@ class ArtplayerToolThumbnail extends Emitter {
|
|||||||
elink.click();
|
elink.click();
|
||||||
document.body.removeChild(elink);
|
document.body.removeChild(elink);
|
||||||
this.emit('download', name);
|
this.emit('download', name);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorHandle(condition, msg) {
|
errorHandle(condition, msg) {
|
||||||
|
|||||||
Reference in new issue
Block a user