mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 13:04:23 +00:00
Player: Improve custom song loading song data resolution
This commit is contained in:
@@ -431,8 +431,13 @@
|
|||||||
parseBlob( blob )
|
parseBlob( blob )
|
||||||
.then( data => {
|
.then( data => {
|
||||||
try {
|
try {
|
||||||
player.findSongOnAppleMusic( data.common.title
|
const searchTerm = data.common.title
|
||||||
?? songDetails.filename.split( '.' )[ 0 ] )
|
? data.common.title + ' ' + data.common.artist
|
||||||
|
: songDetails.filename.split( '.' )[ 0 ];
|
||||||
|
|
||||||
|
console.debug( 'Searching for', searchTerm );
|
||||||
|
|
||||||
|
player.findSongOnAppleMusic( searchTerm )
|
||||||
.then( d => {
|
.then( d => {
|
||||||
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
|
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
|
||||||
|
|
||||||
@@ -560,7 +565,7 @@
|
|||||||
prepNiceDurationTime( playingSong );
|
prepNiceDurationTime( playingSong );
|
||||||
notificationHandler.emit( 'playlist-index-update', currentlyPlayingSongIndex.value );
|
notificationHandler.emit( 'playlist-index-update', currentlyPlayingSongIndex.value );
|
||||||
notificationHandler.emit( 'playback-update', isPlaying.value );
|
notificationHandler.emit( 'playback-update', isPlaying.value );
|
||||||
notificationHandler.emit( 'playback-start-update', new Date().getTime() - pos.value * 1000 );
|
notificationHandler.emit( 'playback-start-update', new Date().getTime() - ( pos.value * 1000 ) );
|
||||||
hasStarted = true;
|
hasStarted = true;
|
||||||
}, 2000 );
|
}, 2000 );
|
||||||
}
|
}
|
||||||
@@ -574,7 +579,7 @@
|
|||||||
nicePlaybackPos.value = '0' + minuteCount + ':';
|
nicePlaybackPos.value = '0' + minuteCount + ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
const secondCount = Math.floor( pos.value - minuteCount * 60 );
|
const secondCount = Math.floor( pos.value - ( minuteCount * 60 ) );
|
||||||
|
|
||||||
if ( ( '' + secondCount ).length === 1 ) {
|
if ( ( '' + secondCount ).length === 1 ) {
|
||||||
nicePlaybackPos.value += '0' + secondCount;
|
nicePlaybackPos.value += '0' + secondCount;
|
||||||
@@ -591,7 +596,7 @@
|
|||||||
niceDuration.value = '-0' + minuteCounts + ':';
|
niceDuration.value = '-0' + minuteCounts + ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
const secondCounts = Math.floor( ( playingSong.duration - pos.value ) - minuteCounts * 60 );
|
const secondCounts = Math.floor( ( playingSong.duration - pos.value ) - ( minuteCounts * 60 ) );
|
||||||
|
|
||||||
if ( ( '' + secondCounts ).length === 1 ) {
|
if ( ( '' + secondCounts ).length === 1 ) {
|
||||||
niceDuration.value += '0' + secondCounts;
|
niceDuration.value += '0' + secondCounts;
|
||||||
|
|||||||
Reference in New Issue
Block a user