mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 18:31:40 +00:00
feat: radio
This commit is contained in:
parent
1deb9ed3d7
commit
a1ee70c24f
16 changed files with 478 additions and 11 deletions
|
|
@ -12,6 +12,7 @@ object Constants {
|
|||
const val GENRE_OBJECT = "GENRE_OBJECT"
|
||||
const val PLAYLIST_OBJECT = "PLAYLIST_OBJECT"
|
||||
const val PODCAST_OBJECT = "PODCAST_OBJECT"
|
||||
const val INTERNET_RADIO_STATION_OBJECT = "INTERNET_RADIO_STATION_OBJECT"
|
||||
|
||||
const val ALBUM_RECENTLY_PLAYED = "ALBUM_RECENTLY_PLAYED"
|
||||
const val ALBUM_MOST_PLAYED = "ALBUM_MOST_PLAYED"
|
||||
|
|
@ -42,6 +43,7 @@ object Constants {
|
|||
const val MEDIA_TYPE_PODCAST = "podcast"
|
||||
const val MEDIA_TYPE_AUDIOBOOK = "audiobook"
|
||||
const val MEDIA_TYPE_VIDEO = "video"
|
||||
const val MEDIA_TYPE_RADIO = "radio"
|
||||
|
||||
const val MEDIA_PLAYBACK_SPEED_080 = 0.8f
|
||||
const val MEDIA_PLAYBACK_SPEED_100 = 1.0f
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import androidx.media3.common.util.UnstableApi;
|
|||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.subsonic.models.InternetRadioStation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -121,6 +122,36 @@ public class MappingUtil {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static MediaItem mapInternetRadioStation(InternetRadioStation internetRadioStation) {
|
||||
Uri uri = Uri.parse(internetRadioStation.getStreamUrl());
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("id", internetRadioStation.getId());
|
||||
bundle.putString("title", internetRadioStation.getName());
|
||||
bundle.putString("artist", uri.toString());
|
||||
bundle.putString("uri", uri.toString());
|
||||
bundle.putString("type", Constants.MEDIA_TYPE_RADIO);
|
||||
|
||||
return new MediaItem.Builder()
|
||||
.setMediaId(internetRadioStation.getId())
|
||||
.setMediaMetadata(
|
||||
new MediaMetadata.Builder()
|
||||
.setTitle(internetRadioStation.getName())
|
||||
.setArtist(internetRadioStation.getStreamUrl())
|
||||
.setExtras(bundle)
|
||||
.build()
|
||||
)
|
||||
.setRequestMetadata(
|
||||
new MediaItem.RequestMetadata.Builder()
|
||||
.setMediaUri(uri)
|
||||
.setExtras(bundle)
|
||||
.build()
|
||||
)
|
||||
.setMimeType(MimeTypes.BASE_TYPE_AUDIO)
|
||||
.setUri(uri)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Uri getUri(Child media) {
|
||||
return DownloadUtil.getDownloadTracker(App.getContext()).isDownloaded(media.getId())
|
||||
? MusicUtil.getDownloadUri(media.getId())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue