Added skip button
This commit is contained in:
parent
220549b30b
commit
d7dce65020
@ -1,7 +1,7 @@
|
|||||||
component AudioPlayer
|
component AudioPlayer
|
||||||
#audio-player
|
#audio-player
|
||||||
#audio-player-controls
|
#audio-player-controls
|
||||||
button#audio-player-prev.audio-player-side-button
|
button#audio-player-prev.audio-player-side-button.action(data-action="playPreviousTrack", data-trigger="click")
|
||||||
RawIcon("step-backward")
|
RawIcon("step-backward")
|
||||||
|
|
||||||
.audio-player-play-pause-container
|
.audio-player-play-pause-container
|
||||||
@ -11,7 +11,7 @@ component AudioPlayer
|
|||||||
button#audio-player-pause.fade-out.action(data-action="pauseAudio", data-trigger="click")
|
button#audio-player-pause.fade-out.action(data-action="pauseAudio", data-trigger="click")
|
||||||
RawIcon("pause")
|
RawIcon("pause")
|
||||||
|
|
||||||
button#audio-player-next.audio-player-side-button
|
button#audio-player-next.audio-player-side-button.action(data-action="playNextTrack", data-trigger="click")
|
||||||
RawIcon("step-forward")
|
RawIcon("step-forward")
|
||||||
|
|
||||||
input#audio-player-volume.action(data-action="setVolume", data-trigger="input", type="range", min="0", max="100", value="50")
|
input#audio-player-volume.action(data-action="setVolume", data-trigger="input", type="range", min="0", max="100", value="50")
|
@ -30,6 +30,7 @@ function playAudioFile(arn: AnimeNotifier, trackId: string, trackUrl: string) {
|
|||||||
|
|
||||||
arn.currentSoundTrackId = trackId
|
arn.currentSoundTrackId = trackId
|
||||||
arn.markPlayingSoundTrack()
|
arn.markPlayingSoundTrack()
|
||||||
|
arn.loading(true)
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
let request = new XMLHttpRequest()
|
let request = new XMLHttpRequest()
|
||||||
@ -37,6 +38,8 @@ function playAudioFile(arn: AnimeNotifier, trackId: string, trackUrl: string) {
|
|||||||
request.responseType = "arraybuffer"
|
request.responseType = "arraybuffer"
|
||||||
|
|
||||||
request.onload = () => {
|
request.onload = () => {
|
||||||
|
arn.loading(false)
|
||||||
|
|
||||||
if(currentPlayId !== playId) {
|
if(currentPlayId !== playId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -63,6 +66,10 @@ function playAudioFile(arn: AnimeNotifier, trackId: string, trackUrl: string) {
|
|||||||
}, console.error)
|
}, console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request.onerror = () => {
|
||||||
|
arn.loading(false)
|
||||||
|
}
|
||||||
|
|
||||||
request.send()
|
request.send()
|
||||||
|
|
||||||
// Show audio player
|
// Show audio player
|
||||||
@ -107,6 +114,11 @@ export function toggleAudio(arn: AnimeNotifier, element: HTMLElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Play previous track
|
||||||
|
export async function playPreviousTrack(arn: AnimeNotifier) {
|
||||||
|
alert("Previous track is currently work in progress! Check back later :)")
|
||||||
|
}
|
||||||
|
|
||||||
// Play next track
|
// Play next track
|
||||||
export async function playNextTrack(arn: AnimeNotifier) {
|
export async function playNextTrack(arn: AnimeNotifier) {
|
||||||
// Get random track
|
// Get random track
|
||||||
@ -114,6 +126,7 @@ export async function playNextTrack(arn: AnimeNotifier) {
|
|||||||
let track = await response.json()
|
let track = await response.json()
|
||||||
|
|
||||||
playAudioFile(arn, track.id, "https://notify.moe/audio/" + track.file)
|
playAudioFile(arn, track.id, "https://notify.moe/audio/" + track.file)
|
||||||
|
arn.statusMessage.showInfo("Now playing: " + track.title)
|
||||||
|
|
||||||
return track
|
return track
|
||||||
}
|
}
|
||||||
@ -140,10 +153,9 @@ export function pauseAudio(arn: AnimeNotifier, button: HTMLButtonElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resume audio
|
// Resume audio
|
||||||
export async function resumeAudio(arn: AnimeNotifier, button: HTMLButtonElement) {
|
export function resumeAudio(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||||
if(!audioNode) {
|
if(!audioNode) {
|
||||||
let track = await playNextTrack(arn)
|
playNextTrack(arn)
|
||||||
arn.statusMessage.showInfo("Now playing: " + track.title)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user