Skip to content

Commit

Permalink
Updated dependencies, Updated version to 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwernick committed Sep 30, 2023
1 parent 138b4c3 commit 668c88b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ repositories {
dependencies {
//...
compile 'com.devbrackets.android:playlistcore:2.1.0'
compile 'com.devbrackets.android:playlistcore:2.2.0'
}
```

###### NOTE: for versions before 2.1.0 see [JCenter][JCenter]

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.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
buildscript {
ext.kotlinVersion = '1.8.22'
ext.kotlinVersion = '1.9.10'

repositories {
google()
mavenCentral()
}

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"
}
}
Expand Down
6 changes: 3 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

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

<application
android:name=".App"
android:allowBackup="true"
Expand Down Expand Up @@ -38,9 +42,7 @@
<service
android:name=".service.MediaService"
android:enabled="true"
android:exported="false"/>
android:exported="false"
android:foregroundServiceType="mediaPlayback"/>
</application>

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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<MediaItem>? = 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
Expand All @@ -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)
}
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion libraryInfo.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ARTIFACT_ID = playlistcore
GROUP_ID = com.devbrackets.android

VERSION_MAJOR = 2
VERSION_MINOR = 1
VERSION_MINOR = 2
VERSION_PATCH = 0

0 comments on commit 668c88b

Please sign in to comment.