mediaelement plugins
5.0.0
該存儲庫包含用於MedialementJS的插件。
ES6上的一個單詞2.3.0版本的重要更改作為持續改進的玩家,我們決定完全支持IE9和IE10,因為這些瀏覽器的市場份額為0.4%,根據https://caniuse.com/usage-table。
此更改用於MediaElement和MediaElement Plugins存儲庫。
從https://github.com/mediaelement/mediaelement-plugins下載軟件包,並從dist文件夾中引用您需要的任何插件,並添加與插件相關的任何配置。
或者您可以使用CDN;檢查https://cdnjs.com/libraries/mediaelement-plugins。
例如,如果要安裝Speed插件,請執行以下操作:
< script src =" /path/to/mediaelement-and-player.min.js " > </ script >
<!-- Include any languages from `build/lang` folder -->
< script src =" /path/to/dist/speed/speed.min.js " > </ script >
<!-- Translation file for plugin (includes ALL languages available on player)-->
< script src =" /path/to/dist/speed/speed-i18n.js " > </ script >
< script >
var player = new MediaElementPlayer ( 'playerId' , {
defaultSpeed : 0.75 ,
// other configuration elements
} ) ;
</ script >其中一些將包含CSS樣式,因此將其放在主要播放器樣式之後:
< link rel =" stylesheet " href =" /path/to/mediaelementplayer.min.css " >
< link rel =" stylesheet " href =" /path/to/dist/speed/speed.min.css " >在https://nodejs.org/上下載它,然後按照安裝它的步驟或使用npm安裝node.js
安裝後,在命令提示符下,鍵入npm install ,將下載所有必要的工具。
/src/ Directory中的文件,而永遠不要在/dist/ DIRECTORY中進行更改。這是唯一的目的是促進合併(以及進一步的編譯)操作,並幫助人們更容易看到變化。npm run eslint以確保代碼質量。loop/loop.js )。script配置下使用命令更新package.json ,以確保將其捆綁並正確編譯。有關更多參考,請查看文件。docs/FEATURE_NAME.md文件,描述其目的,API等,並在README文件中添加帶有其文檔的鏈接的名稱,以使文檔保持最新狀態。MediaElement為DOM操縱/AJAX/等的實用程序。檢查此鏈接以獲取更多詳細信息。. mejs__ [ feature_name ] , . mejs- [ feature_name ] {
// all your styles
} 'use strict' ;
/**
* [Name of feature]
*
* [Description]
*/
// If plugin needs translations, put here English one in this format:
// mejs.i18n.en["mejs.id1"] = "String 1";
// mejs.i18n.en["mejs.id2"] = "String 2";
// Feature configuration
Object . assign ( mejs . MepDefaults , {
// Any variable that can be configured by the end user belongs here.
// Make sure is unique by checking API and Configuration file.
// Add comments about the nature of each of these variables.
} ) ;
Object . assign ( MediaElementPlayer . prototype , {
// Public variables (also documented according to JSDoc specifications)
/**
* Feature constructor.
*
* Always has to be prefixed with `build` and the name that will be used in MepDefaults.features list
* @param {MediaElementPlayer} player
* @param {HTMLElement} controls
* @param {HTMLElement} layers
* @param {HTMLElement} media
*/
build [ feature_name ] ( player , controls , layers , media ) {
// This allows us to access options and other useful elements already set.
// Adding variables to the object is a good idea if you plan to reuse
// those variables in further operations.
const t = this ;
// All code required inside here to keep it private;
// otherwise, you can create more methods or add variables
// outside of this scope
} ,
// Optionally, each feature can be destroyed setting a `clean` method
/**
* Feature destructor.
*
* Always has to be prefixed with `clean` and the name that was used in MepDefaults.features list
* @param {MediaElementPlayer} player
* @param {HTMLElement} controls
* @param {HTMLElement} layers
* @param {HTMLElement} media
*/
clean [ feature_name ] ( player , controls , layers , media ) { }
// Other optional public methods (all documented according to JSDoc specifications)
} ) ; 如果可翻譯字符串是插件的一部分,則需要使用此格式創建一個[feature_name]-i18n.js文件:
'use strict' ;
if ( mejs . i18n . ca !== undefined ) {
mejs . i18n . ca [ "mejs.id1" ] = "" ;
}
if ( mejs . i18n . cs !== undefined ) {
mejs . i18n . cs [ "mejs.id1" ] = "" ;
}
// And the rest of the languages注意:集成在MediaElementPlayer上的語言越多,此模板就會越大。
另外,如果您將新語言添加到MediaElementPlayer中,則需要以上面的模板中描述的方式將其添加到所有現有的i18n文件中。
ES6上的一個單詞所有功能均使用Ecmascript 2015規格編寫。
請參閱src/目錄,並檢查如何編寫文件以確保兼容性。
注意:可以使用循環for...of ,但是為了捆綁它們並減少捆綁文件的大小,強烈建議您避免使用。
更改日誌上可用的更改