Skip to content

Commit

Permalink
Set metadata title in onEnded
Browse files Browse the repository at this point in the history
  • Loading branch information
jjuback committed Apr 5, 2024
1 parent 9dfed41 commit d2e7910
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Album.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const Album = (props) => {
<audio controls src={makeUrl(props.Tracks[trackNo].Url)} autoPlay={trackNo > 0}
onEnded={() => {
if (trackNo + 1 < props.Tracks.length) {
navigator.mediaSession.metadata = new MediaMetadata({
title: props.Tracks[trackNo + 1].Title
});
setTrackNo(trackNo + 1);
} else {
props.goBack();
Expand All @@ -32,16 +35,6 @@ export const Album = (props) => {
]
});
}}
onPlaying={() => {
navigator.mediaSession.metadata = new MediaMetadata({
title: props.Tracks[trackNo].Title,
artist: props.Artist,
album: props.Title,
artwork: [
{ src: makeUrl(props.Cover), sizes: '96x96' }
]
});
}}
/>
<ListGroup numbered>
{props && props.Tracks.map((data, key) => {
Expand Down

0 comments on commit d2e7910

Please sign in to comment.