From 61c2b8c7d0b834aa5d981856e5cb33ea7b679e0b Mon Sep 17 00:00:00 2001 From: Joseph Replin Date: Thu, 20 Jul 2023 09:12:05 -0500 Subject: [PATCH] New: Added event trigger (fixes: #264) (#265) Co-authored-by: Oliver Foster --- js/mediaView.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/mediaView.js b/js/mediaView.js index dabf25f..93b43ce 100644 --- a/js/mediaView.js +++ b/js/mediaView.js @@ -329,7 +329,7 @@ class MediaView extends ComponentView { 'media:stop': this.onMediaStop }); - _.bindAll(this, 'onMediaElementPlay', 'onMediaElementPause', 'onMediaElementEnded', 'onMediaElementTimeUpdate', 'onMediaElementSeeking', 'onOverlayClick', 'onMediaElementClick', 'onWidgetInview'); + _.bindAll(this, 'onMediaElementPlay', 'onMediaElementPause', 'onMediaElementEnded', 'onMediaVolumeChange', 'onMediaElementTimeUpdate', 'onMediaElementSeeking', 'onOverlayClick', 'onMediaElementClick', 'onWidgetInview'); // set initial player state attributes this.model.set({ @@ -495,7 +495,8 @@ class MediaView extends ComponentView { $(this.mediaElement).on({ play: this.onMediaElementPlay, pause: this.onMediaElementPause, - ended: this.onMediaElementEnded + ended: this.onMediaElementEnded, + volumechange: this.onMediaVolumeChange }); // occasionally the mejs code triggers a click of the captions language @@ -593,6 +594,10 @@ class MediaView extends ComponentView { } } + onMediaVolumeChange(event) { + Adapt.trigger('media:volumeChange', this.model, this.mediaElement.muted, this.mediaElement.volume); + } + onWidgetInview(event, isInView) { if (!isInView && !this.mediaElement.paused) this.mediaElement.player.pause(); } @@ -701,7 +706,8 @@ class MediaView extends ComponentView { pause: this.onMediaElementPause, ended: this.onMediaElementEnded, seeking: this.onMediaElementSeeking, - timeupdate: this.onMediaElementTimeUpdate + timeupdate: this.onMediaElementTimeUpdate, + volumechange: this.onMediaVolumeChange }); this.mediaElement.src = '';