I would like to send intents for a continuous stream of videos, but all intents, except for the first one (sent with youtube closed) seem to be ignored, and youtube just follows the autoplay recommendation.
Here's the intents I'm attempting to send (Kotlin, Jetpack Compose, SDK 12):
object SongListener {
private val TAG = SongListener::class.simpleName
fun receivedSong(song: QueueSong) {
Log.d(TAG, "Received song: $song")
songsQueue.add(song)
val appIntent = Intent(Intent.ACTION_VIEW, Uri.parse(song.link))
appIntent.flags += Intent.FLAG_ACTIVITY_NEW_TASK
appIntent.flags += Intent.FLAG_ACTIVITY_CLEAR_TASK
appIntent.flags += Intent.FLAG_ACTIVITY_CLEAR_TOP
// appIntent.putExtra("force_fullscreen", true)
// appIntent.putExtra("finish_on_ended", true)
if (AppConf.context == null) Log.d("XXX", "Context is null!")
try {
AppConf.context?.startActivity(appIntent)
} catch (e: Exception) {
Log.e("XXX", e.message ?: "PLM")
}
}
}