Skip to content

Commit

Permalink
Merge pull request #2918 from video-dev/bugfix/prevent-unnecessary-pa…
Browse files Browse the repository at this point in the history
…use-and-seek-on-immediate-switch

Prevent immediate level switch unnecessary pause and seek
  • Loading branch information
robwalch committed Jul 24, 2020
2 parents 7d33a7f + 2eb5f60 commit 55d4e80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/controller/stream-controller.js
Expand Up @@ -571,7 +571,9 @@ class StreamController extends BaseStreamController {
let media = this.media, previouslyPaused;
if (media) {
previouslyPaused = media.paused;
media.pause();
if (!previouslyPaused) {
media.pause();
}
} else {
// don't restart playback after instant level switch in case media not attached
previouslyPaused = true;
Expand All @@ -597,7 +599,7 @@ class StreamController extends BaseStreamController {
const media = this.media;
if (media && media.buffered.length) {
this.immediateSwitch = false;
if (BufferHelper.isBuffered(media, media.currentTime)) {
if (media.currentTime > 0 && BufferHelper.isBuffered(media, media.currentTime)) {
// only nudge if currentTime is buffered
media.currentTime -= 0.0001;
}
Expand Down

0 comments on commit 55d4e80

Please sign in to comment.