Skip to content

Commit

Permalink
fix: 使編輯筆記後回復影片播放狀態,不是強制播放
Browse files Browse the repository at this point in the history
  • Loading branch information
raccoon-lee authored and Raccoon committed Aug 27, 2018
1 parent 85b6c15 commit c2bb234
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 25 deletions.
41 changes: 35 additions & 6 deletions dist/plyr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plyr.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.min.js.map

Large diffs are not rendered by default.

41 changes: 35 additions & 6 deletions dist/plyr.polyfilled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plyr.polyfilled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.polyfilled.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plyr.polyfilled.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hahow-plyr",
"version": "1.3.3",
"version": "1.3.4",
"description":
"A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "https://plyr.io",
Expand Down
41 changes: 35 additions & 6 deletions src/js/plugins/lectureNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default class LectureNote {
this.lectureNoteContainer = null;
this.addLectureNoteButtonStatus = AddLectureNoteButtonStatus.Hidden;
this.isLoadedLectureNote = false;

this.beforeAddLectureNotePlayerState = null;
this.beforeEditLectureNotePlayerState = null;
}

setup () {
Expand Down Expand Up @@ -108,6 +111,14 @@ export default class LectureNote {
}

addLectureNote () {
if (this.player.playing) {
this.beforeAddLectureNotePlayerState = 'playing';
} else {
this.beforeAddLectureNotePlayerState = 'pause';
}

this.player.pause();

const time = Math.round(this.player.currentTime);
const note = this.getSameTimeLectureNote(time);
if (note) {
Expand Down Expand Up @@ -276,11 +287,18 @@ export default class LectureNote {

// 點擊 container 開啟編輯模式
contentContainer.addEventListener('click', (e) => {
toggleClass(contentContainer, 'lecture-note__content-container--edit', true);
lectureNote.showStatus = LectureNoteModel.ShowStatus.Edit;
contentTextarea.style.height = 'auto';
contentTextarea.style.height = `${contentTextarea.scrollHeight}px`;
contentTextarea.focus();
if (lectureNote.showStatus !== LectureNoteModel.ShowStatus.Edit) {
if (this.player.playing) {
this.beforeEditLectureNotePlayerState = 'playing';
} else {
this.beforeEditLectureNotePlayerState = 'pause';
}
toggleClass(contentContainer, 'lecture-note__content-container--edit', true);
lectureNote.showStatus = LectureNoteModel.ShowStatus.Edit;
contentTextarea.style.height = 'auto';
contentTextarea.style.height = `${contentTextarea.scrollHeight}px`;
contentTextarea.focus();
}
});


Expand Down Expand Up @@ -318,7 +336,18 @@ export default class LectureNote {
lectureNote,
});
try{
this.player.play();
if (this.beforeAddLectureNotePlayerState) {
if (this.beforeAddLectureNotePlayerState === 'playing') {
this.player.play();
}
this.beforeAddLectureNotePlayerState = null;
}
if (this.beforeEditLectureNotePlayerState) {
if (this.beforeEditLectureNotePlayerState === 'playing') {
this.player.play();
}
this.beforeEditLectureNotePlayerState = null;
}
} catch (e) {
// ignore
}
Expand Down

0 comments on commit c2bb234

Please sign in to comment.