diff --git a/assets/js/video-player.js b/assets/js/video-player.js index fe52c533..8f0e461f 100644 --- a/assets/js/video-player.js +++ b/assets/js/video-player.js @@ -65,6 +65,8 @@ this.poster = this.el.dataset.poster || ''; this.type = this.el.dataset.type || detectType(this.src); this.autoplay = this.el.dataset.autoplay === 'true'; + this.loop = this.el.dataset.loop === 'true'; + this.muted = this.el.dataset.muted === 'true' || this.autoplay; this.init(); } @@ -76,8 +78,10 @@ this.video.controls = true; this.video.playsInline = true; this.video.preload = this.autoplay ? 'auto' : 'metadata'; + if (this.loop) this.video.loop = true; + if (this.muted) this.video.muted = true; if (this.poster) this.video.poster = this.poster; - this.video.style.cssText = 'display:block;width:100%;height:auto;max-height:70vh;'; + this.video.style.cssText = 'display:block;width:100%;height:100%;object-fit:contain;max-height:none;'; // Play overlay this.overlay = document.createElement('div'); diff --git a/src/AKSRT/Widgets/WidgetVideoPlayer.php b/src/AKSRT/Widgets/WidgetVideoPlayer.php index d20a2d0f..fde4bf8c 100644 --- a/src/AKSRT/Widgets/WidgetVideoPlayer.php +++ b/src/AKSRT/Widgets/WidgetVideoPlayer.php @@ -1,6 +1,6 @@ __('侧栏/流体区嵌入视频播放器。', 'aksrt')] + [ + 'description' => __('侧栏/流体区嵌入视频(共享 aksrt-video 播放器)。', 'aksrt'), + 'classname' => 'widget_aksrt_video_player', + ] ); } @@ -31,6 +34,12 @@ class WidgetVideoPlayer extends \WP_Widget { $aspect = (string) ($instance['aspect_ratio'] ?? ''); if ($video_url === '') { + if (current_user_can('manage_options')) { + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo '
-