Started working on custom track player

This commit is contained in:
Eduard Urbach 2018-03-11 13:03:13 +01:00
parent ecea644b9d
commit 26703c467a
4 changed files with 11 additions and 3 deletions

View File

@ -12,6 +12,9 @@ component SoundTrackContent(track *arn.SoundTrack, media *arn.ExternalMedia)
a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID) a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
img.sound-track-anime-image.lazy(data-src=track.MainAnime().Image("medium"), data-webp="true", alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical) img.sound-track-anime-image.lazy(data-src=track.MainAnime().Image("medium"), data-webp="true", alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
if track.File != "" && media.Service == "Youtube"
img.soundtrack-image.action.lazy(data-action="playAudio", data-trigger="click", data-audio-src="https://notify.moe/audio/" + track.File, data-src="https://img.youtube.com/vi/" + media.ServiceID + "/maxresdefault.jpg", alt=track.Title)
else
ExternalMedia(media) ExternalMedia(media)
component SoundTrackFooter(track *arn.SoundTrack) component SoundTrackFooter(track *arn.SoundTrack)

View File

@ -16,7 +16,7 @@ component Track(track *arn.SoundTrack, user *arn.User)
if user != nil && media.Service == "Youtube" && track.File != "" if user != nil && media.Service == "Youtube" && track.File != ""
.buttons .buttons
button.action(data-action="playAudio", data-trigger="click", data-src="/audio/" + track.File) button.action(data-action="playAudio", data-trigger="click", data-audio-src="/audio/" + track.File)
Icon("play") Icon("play")
span Play in background span Play in background

View File

@ -17,6 +17,11 @@
iframe iframe
width 100% width 100%
.soundtrack-image
object-fit cover
width 100%
height 200px
.sound-track-footer .sound-track-footer
text-align center text-align center
margin-bottom 1rem margin-bottom 1rem

View File

@ -24,7 +24,7 @@ export function playAudio(arn: AnimeNotifier, button: HTMLButtonElement) {
// Request // Request
let request = new XMLHttpRequest() let request = new XMLHttpRequest()
request.open("GET", button.dataset.src, true) request.open("GET", button.dataset.audioSrc, true)
request.responseType = "arraybuffer" request.responseType = "arraybuffer"
request.onload = () => { request.onload = () => {