|
@@ -177,7 +177,7 @@ class DPlayer {
|
|
/**
|
|
/**
|
|
* Play video
|
|
* Play video
|
|
*/
|
|
*/
|
|
- play() {
|
|
|
|
|
|
+ play(fromNative) {
|
|
this.paused = false;
|
|
this.paused = false;
|
|
if (this.video.paused && !utils.isMobile) {
|
|
if (this.video.paused && !utils.isMobile) {
|
|
this.bezel.switch(Icons.play);
|
|
this.bezel.switch(Icons.play);
|
|
@@ -186,12 +186,14 @@ class DPlayer {
|
|
this.template.playButton.innerHTML = Icons.pause;
|
|
this.template.playButton.innerHTML = Icons.pause;
|
|
this.template.mobilePlayButton.innerHTML = Icons.pause;
|
|
this.template.mobilePlayButton.innerHTML = Icons.pause;
|
|
|
|
|
|
- const playedPromise = Promise.resolve(this.video.play());
|
|
|
|
- playedPromise
|
|
|
|
- .catch(() => {
|
|
|
|
- this.pause();
|
|
|
|
- })
|
|
|
|
- .then(() => {});
|
|
|
|
|
|
+ if (!fromNative) {
|
|
|
|
+ const playedPromise = Promise.resolve(this.video.play());
|
|
|
|
+ playedPromise
|
|
|
|
+ .catch(() => {
|
|
|
|
+ this.pause();
|
|
|
|
+ })
|
|
|
|
+ .then(() => {});
|
|
|
|
+ }
|
|
this.timer.enable('loading');
|
|
this.timer.enable('loading');
|
|
this.container.classList.remove('dplayer-paused');
|
|
this.container.classList.remove('dplayer-paused');
|
|
this.container.classList.add('dplayer-playing');
|
|
this.container.classList.add('dplayer-playing');
|
|
@@ -210,7 +212,7 @@ class DPlayer {
|
|
/**
|
|
/**
|
|
* Pause video
|
|
* Pause video
|
|
*/
|
|
*/
|
|
- pause() {
|
|
|
|
|
|
+ pause(fromNative) {
|
|
this.paused = true;
|
|
this.paused = true;
|
|
this.container.classList.remove('dplayer-loading');
|
|
this.container.classList.remove('dplayer-loading');
|
|
|
|
|
|
@@ -220,7 +222,9 @@ class DPlayer {
|
|
|
|
|
|
this.template.playButton.innerHTML = Icons.play;
|
|
this.template.playButton.innerHTML = Icons.play;
|
|
this.template.mobilePlayButton.innerHTML = Icons.play;
|
|
this.template.mobilePlayButton.innerHTML = Icons.play;
|
|
- this.video.pause();
|
|
|
|
|
|
+ if (!fromNative) {
|
|
|
|
+ this.video.pause();
|
|
|
|
+ }
|
|
this.timer.disable('loading');
|
|
this.timer.disable('loading');
|
|
this.container.classList.remove('dplayer-playing');
|
|
this.container.classList.remove('dplayer-playing');
|
|
this.container.classList.add('dplayer-paused');
|
|
this.container.classList.add('dplayer-paused');
|
|
@@ -486,13 +490,13 @@ class DPlayer {
|
|
|
|
|
|
this.on('play', () => {
|
|
this.on('play', () => {
|
|
if (this.paused) {
|
|
if (this.paused) {
|
|
- this.play();
|
|
|
|
|
|
+ this.play(true);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
this.on('pause', () => {
|
|
this.on('pause', () => {
|
|
if (!this.paused) {
|
|
if (!this.paused) {
|
|
- this.pause();
|
|
|
|
|
|
+ this.pause(true);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|