Files
Fogwave/app/src/main/java/cc/skysparkle/fogwave/player/StationMediaItems.kt
T
kalarina cca6d5e19c Release 1.0.13
- Add LRT Radijas, Žinių radijas, Latvijas Radio 1 and Latvijas Radio 2
- Add HLS playback (media3-exoplayer-hls) for the Latvijas Radio streams
- Add "News & talk" and "Latvian music" genres
- Show the view options button on the Radio tab only; Favorites uses the same layout
- Update descriptions and changelogs

Inspired by https://github.com/JacobBico/fogwave-baltic
2026-11-08 13:50:10 +02:00

31 lines
1.2 KiB
Kotlin

package cc.skysparkle.fogwave.player
import android.content.ContentResolver
import android.content.Context
import androidx.core.net.toUri
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.MimeTypes
import cc.skysparkle.fogwave.data.model.RadioStation
fun RadioStation.toMediaItem(context: Context): MediaItem {
val artworkUri = "${ContentResolver.SCHEME_ANDROID_RESOURCE}://${context.packageName}/$iconResId".toUri()
return MediaItem.Builder()
.setUri(streamUrl)
// HLS playlists are picked up by the HLS module; everything else stays a progressive stream.
.apply { if (streamUrl.substringBefore('?').endsWith(".m3u8")) setMimeType(MimeTypes.APPLICATION_M3U8) }
.setMediaId(id)
.setMediaMetadata(
MediaMetadata.Builder()
.setTitle(name)
.setArtist(context.getString(descriptionRes))
.setStation(name)
.setArtworkUri(artworkUri)
.setIsBrowsable(false)
.setIsPlayable(true)
.setMediaType(MediaMetadata.MEDIA_TYPE_RADIO_STATION)
.build()
)
.build()
}