Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial migration to media3 #61

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.8.2.0"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Aug 16 18:14:46 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
5 changes: 3 additions & 2 deletions kotlin-audio-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 31
compileSdk 33

defaultConfig {
applicationId "com.doublesymmetry.kotlin_audio_sample"
minSdk 21
targetSdk 31
targetSdk 33
versionCode 1
versionName "1.0"

Expand All @@ -32,6 +32,7 @@ android {
buildFeatures {
viewBinding true
}
namespace 'com.doublesymmetry.kotlin_audio_sample'
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions kotlin-audio-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.doublesymmetry.kotlin_audio_sample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
14 changes: 9 additions & 5 deletions kotlin-audio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ group = 'com.github.doublesymmetry'
version = versionNumber

android {
compileSdk 31
compileSdk 33

defaultConfig {
minSdk 21
targetSdk 31
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["runnerBuilder"] = "de.mannodermaus.junit5.AndroidJUnit5Builder"
Expand All @@ -34,13 +34,17 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'com.doublesymmetry.kotlinaudio'
}

dependencies {
implementation 'io.coil-kt:coil:1.4.0'
implementation 'androidx.media:media:1.6.0'
api 'com.google.android.exoplayer:exoplayer:2.18.1'
api 'com.google.android.exoplayer:extension-mediasession:2.18.1'
implementation 'androidx.media3:media3-exoplayer:1.0.0-beta03'
implementation 'androidx.media3:media3-exoplayer-dash:1.0.0-beta03'
implementation 'androidx.media3:media3-exoplayer-hls:1.0.0-beta03'
implementation 'androidx.media3:media3-exoplayer-smoothstreaming:1.0.0-beta03'
implementation 'androidx.media3:media3-session:1.0.0-beta03'
api 'androidx.media3:media3-ui:1.0.0-beta03'
api 'com.jakewharton.timber:timber:5.0.1'

implementation 'androidx.test:rules:1.4.0'
Expand Down
2 changes: 1 addition & 1 deletion kotlin-audio/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.doublesymmetry.kotlinaudio" />
<manifest />
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.doublesymmetry.kotlinaudio.models

import android.os.Bundle
import android.support.v4.media.RatingCompat
//import android.support.v4.media.RatingCompat

sealed class MediaSessionCallback {
class RATING(val rating: RatingCompat, extras: Bundle?): MediaSessionCallback()
// class RATING(val rating: RatingCompat, extras: Bundle?): MediaSessionCallback()
object PLAY : MediaSessionCallback()
object PAUSE : MediaSessionCallback()
object NEXT : MediaSessionCallback()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package com.doublesymmetry.kotlinaudio.models

import com.google.android.exoplayer2.Player

data class PlayWhenReadyChangeData(val playWhenReady: Boolean, val pausedBecauseReachedEnd: Boolean)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.doublesymmetry.kotlinaudio.models

import com.google.android.exoplayer2.metadata.Metadata
import com.google.android.exoplayer2.metadata.flac.VorbisComment
import com.google.android.exoplayer2.metadata.icy.IcyHeaders
import com.google.android.exoplayer2.metadata.icy.IcyInfo
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame
import com.google.android.exoplayer2.metadata.id3.UrlLinkFrame
import com.google.android.exoplayer2.metadata.mp4.MdtaMetadataEntry
import androidx.media3.extractor.metadata.id3.TextInformationFrame
import androidx.media3.common.Metadata
import androidx.media3.extractor.metadata.icy.IcyHeaders
import androidx.media3.extractor.metadata.icy.IcyInfo
import androidx.media3.extractor.metadata.id3.UrlLinkFrame
import androidx.media3.extractor.metadata.mp4.MdtaMetadataEntry
import androidx.media3.extractor.metadata.vorbis.VorbisComment

data class PlaybackMetadata(
val source: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.doublesymmetry.kotlinaudio.models

import com.google.android.exoplayer2.C
import com.doublesymmetry.kotlinaudio.models.AudioContentType

data class PlayerConfig(
/**
* Toggle whether or not a player action triggered from an outside source should be intercepted.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.doublesymmetry.kotlinaudio.models

import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.Player
import androidx.media3.common.Player
import androidx.media3.exoplayer.ExoPlayer

interface QueuedPlayerOptions : PlayerOptions {
override var alwaysPauseOnInterruption: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import androidx.media3.common.Player
import androidx.media3.ui.PlayerNotificationManager
import coil.imageLoader
import coil.request.Disposable
import coil.request.ImageRequest
import com.doublesymmetry.kotlinaudio.models.AudioItem
import com.doublesymmetry.kotlinaudio.models.AudioItemHolder
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.PlayerNotificationManager

interface NotificationMetadataProvider {
fun getTitle(): String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ package com.doublesymmetry.kotlinaudio.notification
import android.app.Notification
import android.content.Context
import android.graphics.Color
import android.support.v4.media.session.MediaSessionCompat
import androidx.media3.common.Player
import androidx.media3.session.MediaSession
import androidx.media3.session.SessionToken
import androidx.media3.ui.PlayerNotificationManager
import com.doublesymmetry.kotlinaudio.R
import com.doublesymmetry.kotlinaudio.event.NotificationEventHolder
import com.doublesymmetry.kotlinaudio.models.*
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
import com.google.android.exoplayer2.ui.PlayerNotificationManager
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch

class NotificationManager internal constructor(
private val context: Context,
private val player: Player,
private val mediaSessionToken: MediaSessionCompat.Token,
private val mediaSessionConnector: MediaSessionConnector,
private val mediaSession: MediaSession,
val event: NotificationEventHolder
) : PlayerNotificationManager.NotificationListener {
private lateinit var descriptionAdapter: DescriptionAdapter
Expand Down Expand Up @@ -213,7 +212,6 @@ class NotificationManager internal constructor(
}
}

setMediaSessionToken(mediaSessionToken)
setPlayer(player)
}
}
Expand Down Expand Up @@ -241,8 +239,8 @@ class NotificationManager internal constructor(

private fun reload() = scope.launch {
internalNotificationManager?.invalidate()
mediaSessionConnector.invalidateMediaSessionQueue()
mediaSessionConnector.invalidateMediaSessionMetadata()
// mediaSession.invalidateMediaSessionQueue()
// mediaSession.invalidateMediaSessionMetadata()
}

private fun hideAllButtonsByDefault() {
Expand Down
Loading