Skip to content

Commit

Permalink
Merge pull request #71 from hyperaudio/69-soundcloud-performance
Browse files Browse the repository at this point in the history
Fix for #69 and #70
  • Loading branch information
maboa authored Sep 15, 2021
2 parents 2e9bb8e + a15ed6c commit 274e936
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion js/hyperaudio-lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class HyperaudioLite {
// Auto-play started
});
}
} else if (playerType === 'soundcloud') {
} else if (this.playerType === 'soundcloud') {
// SoundCloud
this.player.seekTo(start * 1000);
} else {
Expand Down Expand Up @@ -201,6 +201,14 @@ class HyperaudioLite {
if (selection.toString() !== '') {
let fNode = selection.focusNode.parentNode;
let aNode = selection.anchorNode.parentNode;

if (aNode.tagName === "P") {
aNode = selection.anchorNode.nextElementSibling;
}

if (fNode.tagName === "P") {
fNode = selection.focusNode.nextElementSibling;
}

if (aNode.getAttribute('data-m') === null || aNode.className === 'speaker') {
aNode = aNode.nextElementSibling;
Expand Down Expand Up @@ -287,15 +295,20 @@ class HyperaudioLite {

if (this.playerType === 'native') {
this.currentTime = this.player.currentTime;
this.checkStatus();
} else if (this.playerType === 'soundcloud') {
this.player.getPosition(ms => {
this.currentTime = ms / 1000;
this.checkStatus();
});
} else {
// assume YouTube
this.currentTime = this.player.getCurrentTime();
this.checkStatus();
}
}

checkStatus = () => {
//check for end time of shared piece

if (this.end && this.end < this.currentTime) {
Expand Down

0 comments on commit 274e936

Please sign in to comment.