Skip to content

Commit

Permalink
4.9.6 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Apr 27, 2024
1 parent 45e5fbe commit e901142
Show file tree
Hide file tree
Showing 23 changed files with 557 additions and 687 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ android {
// Version code schema (not used):
// "1.2.3-beta4" -> 1020304
// "1.2.3" -> 1020395
versionCode 3020136
versionName "4.9.5"
versionCode 3020137
versionName "4.9.6"

def commit = ""
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package de.test.podcini.service.playback

import ac.mdiq.podcini.storage.model.playback.MediaType
import ac.mdiq.podcini.storage.model.playback.Playable
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPCallback
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPInfo
import ac.mdiq.podcini.playback.base.MediaPlayerBase.PSMPCallback
import ac.mdiq.podcini.playback.base.MediaPlayerBase.PSMPInfo

class CancelablePSMPCallback(private val originalCallback: PSMPCallback) : PSMPCallback {
private var isCancelled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package de.test.podcini.service.playback

import ac.mdiq.podcini.storage.model.playback.MediaType
import ac.mdiq.podcini.storage.model.playback.Playable
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPCallback
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPInfo
import ac.mdiq.podcini.playback.base.MediaPlayerBase.PSMPCallback
import ac.mdiq.podcini.playback.base.MediaPlayerBase.PSMPInfo

open class DefaultPSMPCallback : PSMPCallback {
override fun statusChanged(newInfo: PSMPInfo?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package de.test.podcini.service.playback
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
import ac.mdiq.podcini.playback.service.LocalPSMP
import ac.mdiq.podcini.playback.service.LocalMediaPlayer
import ac.mdiq.podcini.storage.model.feed.*
import ac.mdiq.podcini.storage.model.playback.Playable
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPInfo
import ac.mdiq.podcini.playback.base.MediaPlayerBase
import ac.mdiq.podcini.playback.base.MediaPlayerBase.PSMPInfo
import ac.mdiq.podcini.playback.base.PlayerStatus
import ac.mdiq.podcini.storage.database.PodDBAdapter.Companion.deleteDatabase
import ac.mdiq.podcini.storage.database.PodDBAdapter.Companion.getInstance
Expand All @@ -31,7 +31,7 @@ import kotlin.concurrent.Volatile
* Test class for LocalPSMP
*/
@MediumTest
class PlaybackServiceMediaPlayerTest {
class MediaPlayerBaseTest {
private var PLAYABLE_LOCAL_URL: String? = null
private var httpServer: HTTPBin? = null
private var playableFileUrl: String? = null
Expand Down Expand Up @@ -97,7 +97,7 @@ class PlaybackServiceMediaPlayerTest {
@UiThreadTest
fun testInit() {
val c = InstrumentationRegistry.getInstrumentation().targetContext
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, DefaultPSMPCallback())
val psmp: MediaPlayerBase = LocalMediaPlayer(c, DefaultPSMPCallback())
psmp.shutdown()
}

Expand Down Expand Up @@ -148,7 +148,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, null)
psmp.playMediaObject(p, true, false, false)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -190,7 +190,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, null)
psmp.playMediaObject(p, true, true, false)

Expand Down Expand Up @@ -238,7 +238,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, null)
psmp.playMediaObject(p, true, false, true)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -287,7 +287,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, null)
psmp.playMediaObject(p, true, true, true)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -327,7 +327,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
psmp.playMediaObject(p, false, false, false)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -368,7 +368,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
psmp.playMediaObject(p, false, true, false)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -414,7 +414,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
psmp.playMediaObject(p, false, false, true)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -463,7 +463,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
psmp.playMediaObject(p, false, true, true)
val res = countDownLatch.await(LATCH_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)
Expand Down Expand Up @@ -519,7 +519,7 @@ class PlaybackServiceMediaPlayerTest {
if (assertionError == null) assertionError = AssertionFailedError("Unexpected call to shouldStop")
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
if (initialState == PlayerStatus.PLAYING) {
psmp.playMediaObject(p, stream, true, true)
Expand Down Expand Up @@ -623,7 +623,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
if (initialState == PlayerStatus.PREPARED || initialState == PlayerStatus.PLAYING || initialState == PlayerStatus.PAUSED) {
val startWhenPrepared = (initialState != PlayerStatus.PREPARED)
psmp.playMediaObject(writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL), false, startWhenPrepared, true)
Expand Down Expand Up @@ -682,7 +682,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
if (initialState == PlayerStatus.INITIALIZED || initialState == PlayerStatus.PLAYING || initialState == PlayerStatus.PREPARED || initialState == PlayerStatus.PAUSED) {
val prepareImmediately = (initialState != PlayerStatus.INITIALIZED)
Expand Down Expand Up @@ -755,7 +755,7 @@ class PlaybackServiceMediaPlayerTest {
}
}
})
val psmp: PlaybackServiceMediaPlayer = LocalPSMP(c, callback)
val psmp: MediaPlayerBase = LocalMediaPlayer(c, callback)
val p = writeTestPlayable(playableFileUrl, PLAYABLE_LOCAL_URL)
val prepareImmediately = initialState != PlayerStatus.INITIALIZED
val startImmediately = initialState != PlayerStatus.PREPARED
Expand Down
6 changes: 3 additions & 3 deletions app/src/free/java/ac/mdiq/podcini/playback/cast/CastPsmp.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package ac.mdiq.podcini.playback.cast

import android.content.Context
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer
import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPCallback
import ac.mdiq.podcini.playback.base.MediaPlayerBase
import ac.mdiq.podcini.playback.base.MediaPlayerBase.PSMPCallback

/**
* Stub implementation of CastPsmp for Free build flavour
*/
object CastPsmp {
@JvmStatic
fun getInstanceIfConnected(context: Context, callback: PSMPCallback): PlaybackServiceMediaPlayer? {
fun getInstanceIfConnected(context: Context, callback: PSMPCallback): MediaPlayerBase? {
return null
}
}
14 changes: 7 additions & 7 deletions app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ac.mdiq.podcini.feed.util.PlaybackSpeedUtils.getCurrentPlaybackSpeed
import ac.mdiq.podcini.preferences.PlaybackPreferences
import ac.mdiq.podcini.playback.service.PlaybackService
import ac.mdiq.podcini.playback.service.PlaybackService.LocalBinder
import ac.mdiq.podcini.playback.service.PlaybackServiceInterface
import ac.mdiq.podcini.playback.service.PlaybackServiceConstants
import ac.mdiq.podcini.storage.DBWriter
import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent
import ac.mdiq.podcini.util.event.playback.PlaybackServiceEvent
Expand Down Expand Up @@ -69,10 +69,10 @@ abstract class PlaybackController(private val activity: FragmentActivity) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
activity.registerReceiver(statusUpdate, IntentFilter(PlaybackService.ACTION_PLAYER_STATUS_CHANGED), Context.RECEIVER_NOT_EXPORTED)
activity.registerReceiver(notificationReceiver, IntentFilter(PlaybackServiceInterface.ACTION_PLAYER_NOTIFICATION), Context.RECEIVER_NOT_EXPORTED)
activity.registerReceiver(notificationReceiver, IntentFilter(PlaybackServiceConstants.ACTION_PLAYER_NOTIFICATION), Context.RECEIVER_NOT_EXPORTED)
} else {
activity.registerReceiver(statusUpdate, IntentFilter(PlaybackService.ACTION_PLAYER_STATUS_CHANGED))
activity.registerReceiver(notificationReceiver, IntentFilter(PlaybackServiceInterface.ACTION_PLAYER_NOTIFICATION))
activity.registerReceiver(notificationReceiver, IntentFilter(PlaybackServiceConstants.ACTION_PLAYER_NOTIFICATION))
}

if (!released) bindToService()
Expand Down Expand Up @@ -184,22 +184,22 @@ abstract class PlaybackController(private val activity: FragmentActivity) {

private val notificationReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val type = intent.getIntExtra(PlaybackServiceInterface.EXTRA_NOTIFICATION_TYPE, -1)
val code = intent.getIntExtra(PlaybackServiceInterface.EXTRA_NOTIFICATION_CODE, -1)
val type = intent.getIntExtra(PlaybackServiceConstants.EXTRA_NOTIFICATION_TYPE, -1)
val code = intent.getIntExtra(PlaybackServiceConstants.EXTRA_NOTIFICATION_CODE, -1)
if (code == -1 || type == -1) {
Log.d(TAG, "Bad arguments. Won't handle intent")
return
}
when (type) {
PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD -> {
PlaybackServiceConstants.NOTIFICATION_TYPE_RELOAD -> {
if (playbackService == null && PlaybackService.isRunning) {
bindToService()
return
}
mediaInfoLoaded = false
queryService()
}
PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END -> onPlaybackEnd()
PlaybackServiceConstants.NOTIFICATION_TYPE_PLAYBACK_END -> onPlaybackEnd()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.os.Parcelable
import androidx.core.content.ContextCompat
import androidx.media3.common.util.UnstableApi
import ac.mdiq.podcini.playback.service.PlaybackService
import ac.mdiq.podcini.playback.service.PlaybackServiceInterface
import ac.mdiq.podcini.playback.service.PlaybackServiceConstants
import ac.mdiq.podcini.storage.model.playback.Playable

@UnstableApi
Expand All @@ -31,8 +31,8 @@ class PlaybackServiceStarter(private val context: Context, private val media: Pl
val intent: Intent
get() {
val launchIntent = Intent(context, PlaybackService::class.java)
launchIntent.putExtra(PlaybackServiceInterface.EXTRA_PLAYABLE, media as Parcelable)
launchIntent.putExtra(PlaybackServiceInterface.EXTRA_ALLOW_STREAM_THIS_TIME, shouldStreamThisTime)
launchIntent.putExtra(PlaybackServiceConstants.EXTRA_PLAYABLE, media as Parcelable)
launchIntent.putExtra(PlaybackServiceConstants.EXTRA_ALLOW_STREAM_THIS_TIME, shouldStreamThisTime)
return launchIntent
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlin.concurrent.Volatile
* Abstract class that allows for different implementations of the PlaybackServiceMediaPlayer for local
* and remote (cast devices) playback.
*/
abstract class PlaybackServiceMediaPlayer protected constructor(protected val context: Context, protected val callback: PSMPCallback) {
abstract class MediaPlayerBase protected constructor(protected val context: Context, protected val callback: PSMPCallback) {

@Volatile
private var oldPlayerStatus: PlayerStatus? = null
Expand Down Expand Up @@ -377,7 +377,8 @@ abstract class PlaybackServiceMediaPlayer protected constructor(protected val co
* Holds information about a PSMP object.
*/
class PSMPInfo(@JvmField val oldPlayerStatus: PlayerStatus?, @JvmField var playerStatus: PlayerStatus, @JvmField var playable: Playable?)

companion object {
private const val TAG = "PlaybackSvcMediaPlayer"
private const val TAG = "MediaPlayerBase"
}
}
Loading

0 comments on commit e901142

Please sign in to comment.