diff --git a/package.json b/package.json index 7812289..aaa47c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "agefans", - "version": "1.12.2", + "version": "1.13.0", "description": "增强agefans播放功能,实现自动换集、无缝换集、画中画、历史记录、断点续播、显示视频源、获取当前页面全部视频等功能", "main": "index.user.js", "scripts": { diff --git a/src/player/index.js b/src/player/index.js index d558044..42000a6 100644 --- a/src/player/index.js +++ b/src/player/index.js @@ -40,6 +40,28 @@ class KPlayer { const $header = $('
') $wrapper.append($video) + this.localConfigKey = 'kplayer' + this.statusSessionKey = 'k-player-status' + + /** + * @type {{speed:number,continuePlay:boolean,autoNext:boolean,showProgress:boolean,volume:number}} + */ + this.localConfig = { + speed: 1, + continuePlay: true, + autoNext: true, + showProgress: true, + volume: 1, + } + try { + this.localConfig = Object.assign( + this.localConfig, + JSON.parse(window.localStorage.getItem(this.localConfigKey)) + ) + } catch (error) { + /** empty */ + } + this.plyr = new Plyr('#k-player', { autoplay: true, keyboard: { global: true }, @@ -57,6 +79,7 @@ class KPlayer { ], storage: false, seekTime: 5, + volume: this.localConfig.volume, speed: { options: speedList }, i18n: { restart: '重播', @@ -110,27 +133,6 @@ class KPlayer { ...opts, }) - this.localConfigKey = 'kplayer' - this.statusSessionKey = 'k-player-status' - - /** - * @type {{speed:number,continuePlay:boolean,autoNext:boolean,showProgress:boolean}} - */ - this.localConfig = { - speed: 1, - continuePlay: true, - autoNext: true, - showProgress: true, - } - try { - this.localConfig = Object.assign( - this.localConfig, - JSON.parse(window.localStorage.getItem(this.localConfigKey)) - ) - } catch (error) { - /** empty */ - } - this.$wrapper = $wrapper this.$loading = $loading this.$error = $error @@ -242,6 +244,9 @@ class KPlayer { this.on('exitfullscreen', () => { this.$videoWrapper.removeClass('k-player-fullscreen') }) + this.on('volumechange', () => { + this.configSaveToLocal('volume', this.plyr.volume) + }) this.on('timeupdate', () => { this.$progress .find('.k-player-progress-current')