Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Added event trigger (fixes: #264) #265

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions js/mediaView.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,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({
Expand Down Expand Up @@ -383,7 +383,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
Expand Down Expand Up @@ -481,6 +482,10 @@ class MediaView extends ComponentView {
}
}

onMediaVolumeChange(event) {
Adapt.trigger('media:volumeChange', this, this.mediaElement.muted, this.mediaElement.volume);
joe-replin marked this conversation as resolved.
Show resolved Hide resolved
}

onWidgetInview(event, isInView) {
if (!isInView && !this.mediaElement.paused) this.mediaElement.player.pause();
}
Expand Down Expand Up @@ -589,7 +594,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 = '';
Expand Down