Skip to content

Commit

Permalink
Fixes for video auto pause/play when thread switching.
Browse files Browse the repository at this point in the history
Need to only start videos that are [autostart][muted] and to remove the
special click handling of attachment videos which is now a generic
function of the Message view.
  • Loading branch information
mayfield committed Jan 31, 2018
1 parent 1bb289f commit a433019
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions app/views/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@
onClick: function(e) {
switch (this.contentType) {
case 'audio':
break;
case 'video':
e.target.paused ? e.target.play() : e.target.pause();
break;
case 'image':
this.handleImageModal();
Expand Down
16 changes: 8 additions & 8 deletions app/views/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
},

onClosed: function(e) {
this.$('video').each(function() {
this.pause();
});
for (const video of this.$('video')) {
video.pause();
}
},

onTitleClick: function(ev) {
Expand Down Expand Up @@ -157,17 +157,17 @@
}
},

onOpened: function() {
onOpened: async function() {
this.msgView.scrollRestore();
this.focusMessageField();
this.model.markRead();
this.$('video').each(function() {
for (const video of this.$('video[autoplay][muted]')) {
try {
this.play();
await video.play();
} catch(e) {
console.warn("Ignore video play error:", e);
console.debug("Ignore video play error:", e);
}
});
}
},

focusMessageField: function() {
Expand Down

0 comments on commit a433019

Please sign in to comment.