Skip to content

Commit

Permalink
🍰 feature no-destroy supported (#6)
Browse files Browse the repository at this point in the history
当播放器的容器带有 `no-destroy` 类时该播放器不会被销毁与重载,适合不间断播放的全站播放器使用。
不影响第一次加载。
  • Loading branch information
AlanDecode authored and metowolf committed Oct 7, 2018
1 parent 3ded125 commit 8c84089
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/Meting.min.js

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

12 changes: 8 additions & 4 deletions src/Meting.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ let loadMeting = () => {
if (typeof meting_api !== 'undefined') api = meting_api;

for (let i = 0; i < aplayers.length; i++) {
try {
aplayers[i].destroy();
} catch (e) {
console.log(e);
if(!aplayers[i].container.classList.contains("no-destroy")){
try {
aplayers[i].destroy();
} catch (e) {
console.log(e);
}
}
}
aplayers = [];
Expand All @@ -18,6 +20,8 @@ let loadMeting = () => {

for (var i = 0; i < elements.length; i++) {
const el = elements[i];
if(el.classList.contains("no-reload")) continue;
if(el.classList.contains("no-destroy")) el.classList.add("no-reload");
let id = el.dataset.id;
if (id) {
let url = el.dataset.api || api;
Expand Down

0 comments on commit 8c84089

Please sign in to comment.