Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
play
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
play
Commits
5c2be4ac
Commit
5c2be4ac
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
feat: update episode/show coverart for stream
parent
daaa629e
No related branches found
No related tags found
No related merge requests found
Pipeline
#3451
failed
1 year ago
Stage: test
Stage: build
Stage: release
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/MediaPlayer.svelte
+76
-24
76 additions, 24 deletions
src/components/MediaPlayer.svelte
with
76 additions
and
24 deletions
src/components/MediaPlayer.svelte
+
76
−
24
View file @
5c2be4ac
<script
lang=
"ts"
>
import
{
onMount
,
onDestroy
,
setContext
}
from
'
svelte
'
import
{
addTrackStore
}
from
'
../stores.js
'
import
{
currentEpisodeStore
}
from
'
../poll.js
'
import
Spinner
from
'
../common/Spinner.svelte
'
import
MediaPlayerCenter
from
'
../elements/MediaPlayerCenter.svelte
'
import
Amplitude
from
'
amplitudejs
'
...
...
@@ -14,7 +15,7 @@
export
var
autoPlay
:
boolean
=
true
export
var
streamUrl
:
string
=
'
https://securestream.o94.at/live.mp3
'
export
var
streamName
:
string
=
'
Radio ORANGE 94.0
'
export
var
streamCover
:
string
=
export
var
stream
Default
Cover
:
string
=
'
https://aura.radio/assets/aura-logo-grayscale.png
'
export
var
urlEpisodeDetail
:
string
=
'
/episode-detail.html?id=
'
export
var
urlShowDetail
:
string
=
'
/show-detail.html?slug=
'
...
...
@@ -40,11 +41,16 @@
let
activeTab
:
{
[
id
:
string
]:
string
}
=
TABS
[
0
]
let
buttonPlayPause
:
any
=
null
let
coverArt
:
string
=
streamCover
let
coverArt
:
string
let
isLive
:
boolean
=
false
//
// Custom Tracks
//
/* Listen to event for adding/playing a custom track */
let
newTrack
:
any
=
{}
const
unsubscribe
=
addTrackStore
.
subscribe
(
const
unsubscribe
CustomTrack
=
addTrackStore
.
subscribe
(
(
value
:
any
)
=>
(
newTrack
=
value
),
)
$
:
if
(
newTrack
)
{
...
...
@@ -54,6 +60,20 @@
if
(
newTrack
.
play
)
Amplitude
.
playSongAtIndex
(
trackQueue
.
length
-
1
)
}
function
updateFileCoverArt
()
{
isLive
=
isLiveStream
()
if
(
!
isLive
)
{
let
index
=
Amplitude
.
getActiveIndex
()
let
song
=
Amplitude
.
getSongAtIndex
(
index
)
coverArt
=
song
.
cover_art_url
}
}
//
// Live Stream
//
/* Queue holding the playlist entries */
$
:
trackQueue
=
[
{
...
...
@@ -62,10 +82,39 @@
album
:
''
,
url
:
streamUrl
,
live
:
true
,
cover_art_url
:
streamCover
,
cover_art_url
:
stream
Default
Cover
,
},
]
function
isLiveStream
()
{
let
index
=
Amplitude
.
getActiveIndex
()
let
song
=
Amplitude
.
getSongAtIndex
(
index
)
return
song
?.
live
}
/* Subscrible to store event on current episode updates */
const
unsubscribeCurrentEpisode
=
currentEpisodeStore
.
subscribe
((
value
:
any
)
=>
updateLiveCoverArt
(
value
),
)
function
updateLiveCoverArt
(
episode
:
any
)
{
if
(
episode
?.
show
?.
image
)
{
let
cover
=
episode
.
show
.
image
console
.
log
(
'
new cover +++
'
,
cover
)
if
(
isLiveStream
()
&&
coverArt
!=
cover
){
coverArt
=
cover
}
}
else
{
coverArt
=
streamDefaultCover
}
}
//
// General
//
/* Initialize the component */
onMount
(()
=>
{
console
.
log
(
'
Initialize AURA Media Player
'
)
...
...
@@ -84,7 +133,7 @@
callbacks
:
{
initialized
:
()
=>
{
if
(
autoPlay
)
Amplitude
.
play
()
update
Current
CoverArt
()
update
File
CoverArt
()
},
pause
:
()
=>
{
console
.
log
(
'
Clicked <pause>
'
)
...
...
@@ -100,7 +149,7 @@
},
song_change
:
()
=>
{
console
.
log
(
'
Song changed
'
)
update
Current
CoverArt
()
update
File
CoverArt
()
},
stop
:
()
=>
{
console
.
log
(
'
Stopped playing
'
)
...
...
@@ -114,17 +163,25 @@
// Add any given media URL in the query parameters to the playlist
let
url
=
new
URL
(
window
.
location
.
href
)
let
trackBase64
=
decodeURIComponent
(
""
+
url
.
searchParams
.
get
(
'
track
'
))
let
trackBase64
=
decodeURIComponent
(
''
+
url
.
searchParams
.
get
(
'
track
'
))
if
(
trackBase64
)
{
let
trackString
=
atob
(
trackBase64
)
let
track
=
JSON
.
parse
(
trackString
)
let
playMediaInUrl
=
url
.
searchParams
.
get
(
'
play
'
)
console
.
log
(
'
Add track via pop-up URL params:
'
,
track
)
trackQueue
.
push
(
track
)
trackQueue
=
trackQueue
if
(
playMediaInUrl
)
Amplitude
.
playSongAtIndex
(
trackQueue
.
length
-
1
)
let
track
:
any
try
{
if
(
trackString
)
track
=
JSON
.
parse
(
trackString
)
}
catch
(
error
)
{
console
.
log
(
`Error while parsing track in URI: '{trackString}'`
,
error
)
}
if
(
track
)
{
let
playMediaInUrl
=
url
.
searchParams
.
get
(
'
play
'
)
console
.
log
(
'
Add track via pop-up URL params:
'
,
track
)
trackQueue
.
push
(
track
)
trackQueue
=
trackQueue
if
(
playMediaInUrl
)
Amplitude
.
playSongAtIndex
(
trackQueue
.
length
-
1
)
}
}
})
...
...
@@ -137,14 +194,9 @@
else
Amplitude
.
pause
}
function
updateCurrentCoverArt
()
{
let
index
=
Amplitude
.
getActiveIndex
()
let
song
=
Amplitude
.
getSongAtIndex
(
index
)
coverArt
=
song
.
cover_art_url
}
/* Destroy the component */
onDestroy
(
unsubscribe
)
/* Destroy the component and events */
onDestroy
(
unsubscribeCustomTrack
)
onDestroy
(
unsubscribeCurrentEpisode
)
</script>
<style
lang=
"scss"
>
...
...
@@ -224,7 +276,7 @@
height
:
344px
;
background-size
:
344px
344px
;
background-position
:
center
;
background-size
:
co
ntain
;
background-size
:
co
ver
;
}
/* Tab: Playlist */
...
...
@@ -394,7 +446,7 @@
{
/if
}
</div>
<MediaPlayerCenter
/>
<MediaPlayerCenter
{
isLive
}
/>
<div
id=
"aura-media-player-controls"
>
<div
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment