-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add album name. artist artwork url & preview url to track & play prev…
…iew url Co-authored-by: Michael Rittmeister <dr@schlau.bi>
- Loading branch information
1 parent
922fa91
commit 3cf9a8c
Showing
13 changed files
with
375 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
main/src/main/java/com/github/topi314/lavasrc/ExtendedAudioSourceManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.github.topi314.lavasrc; | ||
|
||
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManager; | ||
import com.sedmelluq.discord.lavaplayer.tools.DataFormatTools; | ||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; | ||
|
||
import java.io.DataInput; | ||
import java.io.DataInputStream; | ||
import java.io.DataOutput; | ||
import java.io.IOException; | ||
|
||
public abstract class ExtendedAudioSourceManager implements AudioSourceManager { | ||
|
||
@Override | ||
public void encodeTrack(AudioTrack track, DataOutput output) throws IOException { | ||
var extendedTrack = (ExtendedAudioTrack) track; | ||
DataFormatTools.writeNullableText(output, extendedTrack.getAlbumName()); | ||
DataFormatTools.writeNullableText(output, extendedTrack.getArtistArtworkUrl()); | ||
DataFormatTools.writeNullableText(output, extendedTrack.getPreviewUrl()); | ||
} | ||
|
||
@Override | ||
public boolean isTrackEncodable(AudioTrack track) { | ||
return true; | ||
} | ||
|
||
protected ExtendedAudioTrackInfo decodeTrack(DataInput input) throws IOException { | ||
String albumName = null; | ||
String artistArtworkUrl = null; | ||
String previewUrl = null; | ||
// Check if the input has more than 8 bytes available, which would indicate that the preview field is present. | ||
// This is done to avoid breaking backwards compatibility with tracks that were saved before the preview field was added. | ||
if (((DataInputStream) input).available() > Long.BYTES) { | ||
albumName = DataFormatTools.readNullableText(input); | ||
artistArtworkUrl = DataFormatTools.readNullableText(input); | ||
previewUrl = DataFormatTools.readNullableText(input); | ||
} | ||
return new ExtendedAudioTrackInfo(albumName, artistArtworkUrl, previewUrl); | ||
} | ||
|
||
protected static class ExtendedAudioTrackInfo { | ||
public final String albumName; | ||
public final String artistArtworkUrl; | ||
public final String previewUrl; | ||
|
||
public ExtendedAudioTrackInfo(String albumName, String artistArtworkUrl, String previewUrl) { | ||
this.albumName = albumName; | ||
this.artistArtworkUrl = artistArtworkUrl; | ||
this.previewUrl = previewUrl; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
main/src/main/java/com/github/topi314/lavasrc/ExtendedAudioTrack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.github.topi314.lavasrc; | ||
|
||
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; | ||
import com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack; | ||
|
||
public abstract class ExtendedAudioTrack extends DelegatedAudioTrack { | ||
|
||
protected final String albumName; | ||
protected final String artistArtworkUrl; | ||
protected final String previewUrl; | ||
|
||
public ExtendedAudioTrack(AudioTrackInfo trackInfo, String albumName, String artistArtworkUrl, String previewUrl) { | ||
super(trackInfo); | ||
this.albumName = albumName; | ||
this.artistArtworkUrl = artistArtworkUrl; | ||
this.previewUrl = previewUrl; | ||
} | ||
|
||
public String getAlbumName() { | ||
return this.albumName; | ||
} | ||
|
||
public String getArtistArtworkUrl() { | ||
return this.artistArtworkUrl; | ||
} | ||
|
||
public String getPreviewUrl() { | ||
return this.previewUrl; | ||
} | ||
|
||
} |
15 changes: 14 additions & 1 deletion
15
main/src/main/java/com/github/topi314/lavasrc/applemusic/AppleMusicAudioTrack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.