
內容簡介
這個簡短、實用的外掛程式會為使用 mediaelement.js 內建 WordPress 短碼所加入的音訊、影片和播放清單元素添加播放按鈕。
每組按鈕都針對頁面上的相應元素進行配置,因此您可以獨立調整多個文件的速度。
目前此外掛程式沒有實現持續性。它只是緩解了使用 HTML API 廣泛調整媒體播放速度的需求。
注意:此外掛程式使用 HTML5 媒體元素 API。任何不支援這些或使用 Flash 播放器後備方案的瀏覽器都會錯失此功能。
開發人員
此外掛程式提供了兩個鉤子。
media-playback-speed-generate-controls 提供一個布林值作為參數。如果您將其返回為 false,這將防止添加媒體播放器的按鈕。這是為高級設置而設計的,其中控件的標記可能手動放置在頁面其他地方,例如固定頁腳。只要控制項遵循內建的標記(位於 body 標記內,具有 playback-rate-button 類(沒有預設樣式,僅用於啟用 DOM 存取)),控件就能正常運作。
'media-playback-speed-data' 提供包含數組作為項目的默認數組,每個數組都有 rate、title 和 label 內容,用於設定播放速度、按鈕的 title 和 aria-title,並調整按鈕文本。
主題和前端
.playback-rate-button.mejs-active 和/或 .playback-rate-button.active-playback-rate CSS 選擇器允許您為每個播放器設置活動速度。
最初 mejs-active 類是為了創建與 media-playback-js 兼容/熟悉的類名。
現在 Gutenberg 不再添加這些,因此現在有意義的是暫時添加兩組類。
版本 2 將棄用 .playback-rate-button.mejs-active 選擇器。
疑難排解
此外掛程式與傳統的 audio、video 和 playlist 短碼配合使用,只要 WordPress 使用 JavaScript 播放器即可運行。
隨著最新的 1.1.1 版本,此外掛程式現在也適用於 HTML5 音訊和視訊播放器,但是您需要實現自己的控件,這些控件具有 playback-rate-button 類,並遵循此類的模式。
HTML5 原始控件沒有播放列表,作者意識到它們使用全局狀態,因此播放速度基於頁面。
目前此外掛程式沒有歷史紀錄,但可以編寫一個姊妹插件並添加鉤子以存儲播放速度。
請確保沒有錯誤的 javascript,或將所有函數包裹在 (function() { // do things })() 塊中,以確保沒有任何干擾此外掛程式。此外掛程式這樣做是為了確保它不會影響您的網站,即使在不支援此外掛程式的瀏覽器和頁面中也是如此。
意見回饋
請隨時建議改進,報告衝突以及/或對整合鉤子等提出建議。
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
This short, handy plugin will add playback buttons to your audio, video & playlist elements added via the built-in WordPress shortcodes for media using mediaelement.js.
Each set of buttons is configured for it’s corresponding element on the page, so you can adjust the speed of multiple files independently.
There is currently no persistence implemented in this plugin. It just scratches an itch to be able to broadly adjust media playback speeds using the HTML api.
NOTE: This uses the HTML5 media Element API. Any browser not supporting these or using the Flash Player fallback will miss out on this functionality.
Developers
Two hooks are provided within this plugin.
media-playback-speed-generate-controls provides a single argument which is a boolean. If you return this as false, this will stop buttons being added to a media player. This is intended for advanced setups where markup for controls might be placed manually elsewhere on the page such as a sticky footer. So long as controls follow the built-in markup (being within the body tag and have a playback-rate-button class (no default styling, used for enabling DOM access only).
‘media-playback-speed-data’ provides the default array containing arrays as items with rate, title and label entries, which set the playback rate, the title and aria-title for the buttons as well as adjust the button text.
Theme & Front-end
The .playback-rate-button.mejs-active and/or .playback-rate-button.active-playback-rate CSS-selectors allow you to style the active speed (per-player).
Initially mejs-active class was added in order to create media-playback-js compatible / familiar class names.
Now that Gutenberg does not add these, it makes sense to for-now add two sets of classes.
The .playback-rate-button.mejs-active selector will be deprecated in version 2.
Troubleshooting
This works with the traditional audio, video and playlist shortcodes so long as WordPress uses the JavaScript player.
With the latest 1.1.1 release this also works for HTML5 audio and video too, however you will need to implement your own controls which have the playback-rate-button class and follow the patterns of this.
HTML5 raw controls do not have a playlist the author is aware of, and they use global state, so playback rate is per-page.
There is currently no history as part of this plugin, however a sister plugin could be authored and hooks added to it to store playback rate.
Please ensure that you have no broken javascript, or wrap all functions in (function() { // do things })() blocks to ensure nothing interferes with this plugin. This plugin does this so that it should not interfere with your site, even in browsers and pages which do not support this plugin.
Feedback
Please feel free to suggest improvements, report conflicts, and/or make suggestions for integration hooks etc.
