1313import xyz .gianlu .librespot .mercury .model .EpisodeId ;
1414import xyz .gianlu .librespot .mercury .model .PlayableId ;
1515import xyz .gianlu .librespot .mercury .model .TrackId ;
16- import xyz .gianlu .librespot .player .ContentRestrictedException ;
17- import xyz .gianlu .librespot .player .GeneralAudioStream ;
18- import xyz .gianlu .librespot .player .NormalizationData ;
19- import xyz .gianlu .librespot .player .Player ;
16+ import xyz .gianlu .librespot .player .*;
2017import xyz .gianlu .librespot .player .codecs .AudioQuality ;
2118import xyz .gianlu .librespot .player .codecs .AudioQualityPreference ;
2219import xyz .gianlu .librespot .player .codecs .SuperAudioFormat ;
@@ -66,13 +63,13 @@ private static Metadata.Track pickAlternativeIfNecessary(@NotNull Metadata.Track
6663 }
6764
6865 @ NotNull
69- public final LoadedStream load (@ NotNull PlayableId id , @ NotNull AudioQualityPreference audioQualityPreference ) throws CdnManager .CdnException , ContentRestrictedException , MercuryClient .MercuryException , IOException {
70- if (id instanceof TrackId ) return loadTrack ((TrackId ) id , audioQualityPreference );
71- else if (id instanceof EpisodeId ) return loadEpisode ((EpisodeId ) id , audioQualityPreference );
66+ public final LoadedStream load (@ NotNull PlayableId id , @ NotNull AudioQualityPreference audioQualityPreference , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws CdnManager .CdnException , ContentRestrictedException , MercuryClient .MercuryException , IOException {
67+ if (id instanceof TrackId ) return loadTrack ((TrackId ) id , audioQualityPreference , haltListener );
68+ else if (id instanceof EpisodeId ) return loadEpisode ((EpisodeId ) id , haltListener );
7269 else throw new IllegalArgumentException ("Unknown PlayableId: " + id );
7370 }
7471
75- public final @ NotNull LoadedStream loadTrack (@ NotNull TrackId id , @ NotNull AudioQualityPreference audioQualityPreference ) throws IOException , MercuryClient .MercuryException , ContentRestrictedException , CdnManager .CdnException {
72+ public final @ NotNull LoadedStream loadTrack (@ NotNull TrackId id , @ NotNull AudioQualityPreference audioQualityPreference , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws IOException , MercuryClient .MercuryException , ContentRestrictedException , CdnManager .CdnException {
7673 Metadata .Track original = session .mercury ().sendSync (MercuryRequests .getTrack (id )).proto ();
7774 Metadata .Track track = pickAlternativeIfNecessary (original );
7875 if (track == null ) {
@@ -83,29 +80,29 @@ public final LoadedStream load(@NotNull PlayableId id, @NotNull AudioQualityPref
8380 throw new FeederException ();
8481 }
8582
86- return loadTrack (track , audioQualityPreference );
83+ return loadTrack (track , audioQualityPreference , haltListener );
8784 }
8885
8986 @ NotNull
90- public final LoadedStream loadTrack (@ NotNull Metadata .Track track , @ NotNull AudioQualityPreference audioQualityPreference ) throws IOException , MercuryClient . MercuryException , CdnManager . CdnException {
87+ public final LoadedStream loadTrack (@ NotNull Metadata .Track track , @ NotNull AudioQualityPreference audioQualityPreference , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws IOException , CdnManager . CdnException , MercuryClient . MercuryException {
9188 Metadata .AudioFile file = audioQualityPreference .getFile (track );
9289 if (file == null ) {
9390 LOGGER .fatal (String .format ("Couldn't find any suitable audio file, available: %s" , AudioQuality .listFormats (track )));
9491 throw new FeederException ();
9592 }
9693
97- return loadTrack (track , file );
94+ return loadTrack (track , file , haltListener );
9895 }
9996
10097 @ NotNull
101- public final LoadedStream loadTrack (@ NotNull Spirc .TrackRef ref , @ NotNull AudioQualityPreference audioQualityPreference ) throws IOException , MercuryClient .MercuryException , CdnManager .CdnException , ContentRestrictedException {
102- return loadTrack (TrackId .fromTrackRef (ref ), audioQualityPreference );
98+ public final LoadedStream loadTrack (@ NotNull Spirc .TrackRef ref , @ NotNull AudioQualityPreference audioQualityPreference , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws IOException , MercuryClient .MercuryException , CdnManager .CdnException , ContentRestrictedException {
99+ return loadTrack (TrackId .fromTrackRef (ref ), audioQualityPreference , haltListener );
103100 }
104101
105102 @ NotNull
106- public abstract LoadedStream loadTrack (@ NotNull Metadata .Track track , @ NotNull Metadata .AudioFile file ) throws IOException , CdnManager .CdnException , MercuryClient .MercuryException ;
103+ public abstract LoadedStream loadTrack (@ NotNull Metadata .Track track , @ NotNull Metadata .AudioFile file , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws IOException , CdnManager .CdnException , MercuryClient .MercuryException ;
107104
108- public final @ NotNull LoadedStream loadEpisode (@ NotNull EpisodeId id , @ NotNull AudioQualityPreference audioQualityPreference ) throws IOException , MercuryClient .MercuryException , CdnManager .CdnException {
105+ public final @ NotNull LoadedStream loadEpisode (@ NotNull EpisodeId id , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws IOException , MercuryClient .MercuryException , CdnManager .CdnException {
109106 Metadata .Episode episode = session .mercury ().sendSync (MercuryRequests .getEpisode (id )).proto ();
110107
111108 Metadata .AudioFile file = null ;
@@ -124,11 +121,11 @@ public final LoadedStream loadTrack(@NotNull Spirc.TrackRef ref, @NotNull AudioQ
124121 throw new FeederException ();
125122 }
126123
127- return loadEpisode (episode , file );
124+ return loadEpisode (episode , file , haltListener );
128125 }
129126
130127 @ NotNull
131- public abstract LoadedStream loadEpisode (@ NotNull Metadata .Episode episode , @ NotNull Metadata .AudioFile file ) throws IOException , CdnManager .CdnException , MercuryClient .MercuryException ;
128+ public abstract LoadedStream loadEpisode (@ NotNull Metadata .Episode episode , @ NotNull Metadata .AudioFile file , @ Nullable AbsChunckedInputStream . HaltListener haltListener ) throws IOException , CdnManager .CdnException , MercuryClient .MercuryException ;
132129
133130 public static class LoadedStream {
134131 public final Metadata .Episode episode ;
0 commit comments