diff --git a/README.md b/README.md
index ef16d1b..27d4cb4 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ repositories {
dependencies {
//...
- compile 'com.devbrackets.android:playlistcore:2.1.0'
+ compile 'com.devbrackets.android:playlistcore:2.2.0'
}
```
@@ -30,13 +30,13 @@ dependencies {
Example
-------
-Due to the length an example would be, please see the Demo app
+Please see the demo app for a comprehensive example of how to implement Playlist services
License
-------
- Copyright 2016-2022 Brian Wernick
+ Copyright 2016-2023 Brian Wernick
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/build.gradle b/build.gradle
index ef71f3f..9e435f0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
buildscript {
- ext.kotlinVersion = '1.8.22'
+ ext.kotlinVersion = '1.9.10'
repositories {
google()
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:8.1.0'
+ classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
diff --git a/demo/build.gradle b/demo/build.gradle
index d02c78e..196ebb7 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -5,18 +5,18 @@ dependencies {
implementation project(':library')
implementation 'androidx.appcompat:appcompat:1.6.1'
- implementation 'androidx.annotation:annotation:1.6.0'
+ implementation 'androidx.annotation:annotation:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// Chromecast support
- implementation 'androidx.mediarouter:mediarouter:1.4.0'
+ implementation 'androidx.mediarouter:mediarouter:1.6.0'
implementation 'com.google.android.gms:play-services-cast-framework:21.3.0'
// Media playback (video and audio) library using ExoPlayer
implementation 'com.devbrackets.android:exomedia:5.0.0'
// Image Loading
- implementation 'com.github.bumptech.glide:glide:4.14.2'
+ implementation 'com.github.bumptech.glide:glide:4.16.0'
}
android {
diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml
index 1c790d8..1d657e4 100644
--- a/demo/src/main/AndroidManifest.xml
+++ b/demo/src/main/AndroidManifest.xml
@@ -1,6 +1,10 @@
+
+
+
+
+ android:exported="false"
+ android:foregroundServiceType="mediaPlayback"/>
-
-
-
diff --git a/demo/src/main/java/com/devbrackets/android/playlistcoredemo/helper/cast/CastMediaPlayer.kt b/demo/src/main/java/com/devbrackets/android/playlistcoredemo/helper/cast/CastMediaPlayer.kt
index c4f7006..d0bdcc6 100644
--- a/demo/src/main/java/com/devbrackets/android/playlistcoredemo/helper/cast/CastMediaPlayer.kt
+++ b/demo/src/main/java/com/devbrackets/android/playlistcoredemo/helper/cast/CastMediaPlayer.kt
@@ -44,16 +44,14 @@ class CastMediaPlayer(
fun onMediaInfoChange(player: CastMediaPlayer)
}
- private val sessionManager: SessionManager by lazy {
- CastContext.getSharedInstance(context, Executors.newSingleThreadExecutor()).result.sessionManager
- }
+ private var sessionManager: SessionManager? = null
private val sessionManagerListener = CastSessionManagerListener()
private var mediaStatusListener: MediaStatusListener? = null
private var remoteConnectionState = RemoteConnectionState.NOT_CONNECTED
private val mediaClient: RemoteMediaClient?
- get() = sessionManager.currentCastSession?.remoteMediaClient
+ get() = sessionManager?.currentCastSession?.remoteMediaClient
override val isPlaying: Boolean
get() = mediaClient?.isPlaying == true
@@ -72,15 +70,8 @@ class CastMediaPlayer(
get() = 0
init {
- sessionManager.addSessionManagerListener(sessionManagerListener, CastSession::class.java)
-
- // Makes sure the connection state is accurate
- sessionManager.currentSession?.let { session ->
- if (session.isConnecting) {
- updateState(RemoteConnectionState.CONNECTING)
- } else if (session.isConnected) {
- updateState(RemoteConnectionState.CONNECTED)
- }
+ CastContext.getSharedInstance(context, Executors.newSingleThreadExecutor()).addOnSuccessListener {
+ initializeWithSessionManager(it.sessionManager)
}
}
@@ -107,7 +98,7 @@ class CastMediaPlayer(
}
override fun release() {
- sessionManager.removeSessionManagerListener(sessionManagerListener, CastSession::class.java)
+ sessionManager?.removeSessionManagerListener(sessionManagerListener, CastSession::class.java)
}
override fun setVolume(left: Float, right: Float) {
@@ -151,6 +142,22 @@ class CastMediaPlayer(
}
}
+ private fun initializeWithSessionManager(manager: SessionManager) {
+ sessionManager?.removeSessionManagerListener(sessionManagerListener, CastSession::class.java)
+ sessionManager = manager
+
+ manager.addSessionManagerListener(sessionManagerListener, CastSession::class.java)
+
+ // Makes sure the connection state is accurate
+ manager.currentSession?.let { session ->
+ if (session.isConnecting) {
+ updateState(RemoteConnectionState.CONNECTING)
+ } else if (session.isConnected) {
+ updateState(RemoteConnectionState.CONNECTED)
+ }
+ }
+ }
+
private fun getMediaInfo(item: MediaItem): MediaInfo {
val contentType = Uri.parse(item.mediaUrl).getContentType()
diff --git a/libraryInfo.properties b/libraryInfo.properties
index 2f1c5ba..739c8fc 100644
--- a/libraryInfo.properties
+++ b/libraryInfo.properties
@@ -2,5 +2,5 @@ ARTIFACT_ID = playlistcore
GROUP_ID = com.devbrackets.android
VERSION_MAJOR = 2
-VERSION_MINOR = 1
+VERSION_MINOR = 2
VERSION_PATCH = 0
\ No newline at end of file