mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
优化预览图demo
This commit is contained in:
1 parent
e269d89821
commit
da2df1aa95
3 files changed
+62
-74
No files matched your search
@@ -170,6 +170,10 @@ img {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.part-right .video-wrap .artplayer-app {
|
.part-right .video-wrap .artplayer-app {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 20px;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
height: 65%;
|
height: 65%;
|
||||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
|||||||
@@ -1,78 +1,62 @@
|
|||||||
console.warn('暂时只支持本地视频,请点击创建预览图');
|
|
||||||
var $popups = document.querySelector('.popups');
|
var $popups = document.querySelector('.popups');
|
||||||
var $popinner = document.querySelector('.popinner');
|
var $popinner = document.querySelector('.popinner');
|
||||||
|
var $artplayer = document.querySelector('.artplayer-app');
|
||||||
var url = 'https://zhw2590582.github.io/assets-cdn';
|
var url = 'https://zhw2590582.github.io/assets-cdn';
|
||||||
var art = new Artplayer({
|
|
||||||
container: '.artplayer-app',
|
|
||||||
url: url + '/video/one-more-time-one-more-chance-480p.mp4',
|
|
||||||
title: '【新海诚动画】『秒速5センチメートル』',
|
|
||||||
autoSize: true,
|
|
||||||
moreVideoAttr: {
|
|
||||||
crossOrigin: 'anonymous',
|
|
||||||
},
|
|
||||||
controls: [
|
|
||||||
{
|
|
||||||
name: 'thumbnail',
|
|
||||||
position: 'right',
|
|
||||||
html: '创建预览图',
|
|
||||||
mounted: $file => {
|
|
||||||
var thumbnail = new ArtplayerToolThumbnail({
|
|
||||||
fileInput: $file,
|
|
||||||
delay: 300,
|
|
||||||
number: 60,
|
|
||||||
width: 160,
|
|
||||||
height: 90,
|
|
||||||
column: 10,
|
|
||||||
});
|
|
||||||
|
|
||||||
thumbnail.on('file', function(file) {
|
$artplayer.innerHTML = 'Drop video file here or click to upload.';
|
||||||
console.log('Read video successfully: ' + file.name);
|
var thumbnail = new ArtplayerToolThumbnail({
|
||||||
});
|
fileInput: $artplayer,
|
||||||
|
delay: 300,
|
||||||
thumbnail.on('video', function(video) {
|
number: 60,
|
||||||
console.log('Video size: ' + video.videoWidth + ' x ' + video.videoHeight);
|
width: 160,
|
||||||
console.log('Video duration: ' + video.duration + 's');
|
height: 90,
|
||||||
thumbnail.start();
|
column: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('canvas', function(canvas) {
|
thumbnail.on('file', function(file) {
|
||||||
console.log('Build canvas successfully');
|
console.log('Read video successfully: ' + file.name);
|
||||||
console.log('Canvas size: ' + canvas.width + ' x ' + canvas.height);
|
});
|
||||||
console.log('Preview density: ' + thumbnail.density + ' p/s');
|
|
||||||
});
|
thumbnail.on('video', function(video) {
|
||||||
|
console.log('Video size: ' + video.videoWidth + ' x ' + video.videoHeight);
|
||||||
thumbnail.on('update', function(url, percentage) {
|
console.log('Video duration: ' + video.duration + 's');
|
||||||
console.log('Processing: ' + Math.floor(percentage.toFixed(2) * 100) + '%');
|
thumbnail.start();
|
||||||
$popups.style.display = 'flex';
|
});
|
||||||
$popinner.style.backgroundImage = 'url(' + url + ')';
|
|
||||||
});
|
thumbnail.on('canvas', function(canvas) {
|
||||||
|
console.log('Build canvas successfully');
|
||||||
thumbnail.on('download', function(name) {
|
console.log('Canvas size: ' + canvas.width + ' x ' + canvas.height);
|
||||||
console.log('Start download preview: ' + name);
|
console.log('Preview density: ' + thumbnail.density + ' p/s');
|
||||||
});
|
});
|
||||||
|
|
||||||
thumbnail.on('done', function() {
|
thumbnail.on('update', function(url, percentage) {
|
||||||
$popups.style.display = 'none';
|
console.log('Processing: ' + Math.floor(percentage.toFixed(2) * 100) + '%');
|
||||||
thumbnail.download();
|
$popups.style.display = 'flex';
|
||||||
console.log('Build preview image complete');
|
$popinner.style.backgroundImage = 'url(' + url + ')';
|
||||||
Artplayer.instances.forEach(function(art) {
|
});
|
||||||
art.destroy(true);
|
|
||||||
});
|
thumbnail.on('download', function(name) {
|
||||||
|
console.log('Start download preview: ' + name);
|
||||||
new Artplayer({
|
});
|
||||||
container: '.artplayer-app',
|
|
||||||
url: thumbnail.videoUrl,
|
thumbnail.on('done', function() {
|
||||||
thumbnails: {
|
$popups.style.display = 'none';
|
||||||
url: thumbnail.thumbnailUrl,
|
thumbnail.download();
|
||||||
number: thumbnail.option.number,
|
console.log('Build preview image complete');
|
||||||
width: thumbnail.option.width,
|
Artplayer.instances.forEach(function(art) {
|
||||||
height: thumbnail.option.height,
|
art.destroy(true);
|
||||||
column: thumbnail.option.column,
|
});
|
||||||
},
|
|
||||||
});
|
new Artplayer({
|
||||||
console.log('Build player complete');
|
container: $artplayer,
|
||||||
});
|
url: thumbnail.videoUrl,
|
||||||
},
|
thumbnails: {
|
||||||
},
|
url: thumbnail.thumbnailUrl,
|
||||||
],
|
number: thumbnail.option.number,
|
||||||
|
width: thumbnail.option.width,
|
||||||
|
height: thumbnail.option.height,
|
||||||
|
column: thumbnail.option.column,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log('Build player complete');
|
||||||
});
|
});
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
function initArt(art) {
|
function initArt(art) {
|
||||||
Artplayer.config.video.events.forEach(function(item) {
|
Artplayer.config.video.events.forEach(function(item) {
|
||||||
art.on('video:' + item, function(event) {
|
art && art.on('video:' + item, function(event) {
|
||||||
console.log('video: ' + event.type);
|
console.log('video: ' + event.type);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user