Skip to content

Commit

Permalink
6.11.3 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Oct 16, 2024
1 parent 61ce79f commit a38d776
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 237 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
testApplicationId "ac.mdiq.podcini.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

versionCode 3020272
versionName "6.11.2"
versionCode 3020273
versionName "6.11.3"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class FeedBuilder(val context: Context, val showError: (String?, String)->Unit)
val eList: MutableList<Episode> = mutableListOf()

val uURL = URL(url)
// if (url.startsWith("https://youtube.com/playlist?") || url.startsWith("https://music.youtube.com/playlist?")) {
if (uURL.path.startsWith("/playlist") || uURL.path.startsWith("/playlist")) {
val playlistInfo = PlaylistInfo.getInfo(Vista.getService(0), url) ?: return@launch
feed_.title = playlistInfo.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1436,10 +1436,10 @@ class PlaybackService : MediaLibraryService() {
Logd(TAG, "setDataSource1 audioStreamsList ${audioStreamsList.size}")
val audioIndex = if (isNetworkRestricted && prefLowQualityMedia) 0 else audioStreamsList.size - 1
val audioStream = audioStreamsList[audioIndex]
Logd(TAG, "setDataSource1 use audio quality: ${audioStream.bitrate}")
Logd(TAG, "setDataSource1 use audio quality: ${audioStream.bitrate} forceVideo: ${media.forceVideo}")
val aSource = DefaultMediaSourceFactory(context).createMediaSource(
MediaItem.Builder().setMediaMetadata(metadata).setTag(metadata).setUri(Uri.parse(audioStream.content)).build())
if (media.episode?.feed?.preferences?.videoModePolicy != VideoMode.AUDIO_ONLY) {
if (media.forceVideo || media.episode?.feed?.preferences?.videoModePolicy != VideoMode.AUDIO_ONLY) {
Logd(TAG, "setDataSource1 result: $streamInfo")
Logd(TAG, "setDataSource1 videoStreams: ${streamInfo.videoStreams.size} videoOnlyStreams: ${streamInfo.videoOnlyStreams.size} audioStreams: ${streamInfo.audioStreams.size}")
val videoStreamsList = getSortedStreamVideosList(streamInfo.videoStreams, streamInfo.videoOnlyStreams, true, true)
Expand Down Expand Up @@ -2502,12 +2502,10 @@ class PlaybackService : MediaLibraryService() {

private fun setToFallbackSpeed(speed: Float) {
if (playbackService?.mPlayer == null || playbackService!!.isSpeedForward) return

if (!playbackService!!.isFallbackSpeed) {
playbackService!!.normalSpeed = playbackService!!.mPlayer!!.getPlaybackSpeed()
playbackService!!.mPlayer!!.setPlaybackParams(speed, isSkipSilence)
} else playbackService!!.mPlayer!!.setPlaybackParams(playbackService!!.normalSpeed, isSkipSilence)

playbackService!!.isFallbackSpeed = !playbackService!!.isFallbackSpeed
}

Expand All @@ -2526,6 +2524,7 @@ class PlaybackService : MediaLibraryService() {
playbackService?.mPlayer?.pause(true, reinit = false)
playbackService?.isSpeedForward = false
playbackService?.isFallbackSpeed = false
(curMedia as? EpisodeMedia)?.forceVideo = false
}
PlayerStatus.PAUSED, PlayerStatus.PREPARED -> {
playbackService?.mPlayer?.resume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import ac.mdiq.podcini.util.showStackTrace
import android.content.Context
import android.os.Parcel
import android.os.Parcelable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import io.realm.kotlin.ext.isManaged
import io.realm.kotlin.types.EmbeddedRealmObject
import io.realm.kotlin.types.annotations.Ignore
Expand Down Expand Up @@ -68,6 +71,9 @@ class EpisodeMedia: EmbeddedRealmObject, Playable {
// if null: unknown, will be checked
var hasEmbeddedPicture: Boolean? = null

@Ignore
var forceVideo by mutableStateOf(false)

/* Used for loading item when restoring from parcel. */
// var episodeId: Long = 0
// private set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ abstract class EpisodeActionButton internal constructor(@JvmField var item: Epis
Card(modifier = Modifier.wrapContentSize(align = Alignment.Center).padding(16.dp), shape = RoundedCornerShape(16.dp)) {
Row(modifier = Modifier.padding(16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
val label = getLabel()
Logd(TAG, "button label: $label")
if (label != R.string.play_label && label != R.string.pause_label && label != R.string.download_label) {
IconButton(onClick = {
PlayActionButton(item).onClick(context)
Expand Down Expand Up @@ -140,9 +141,9 @@ abstract class EpisodeActionButton internal constructor(@JvmField var item: Epis

fun playVideoIfNeeded(context: Context, media: Playable) {
val item = (media as? EpisodeMedia)?.episode
if (item?.feed?.preferences?.videoModePolicy != VideoMode.AUDIO_ONLY
if ((media as? EpisodeMedia)?.forceVideo == true || (item?.feed?.preferences?.videoModePolicy != VideoMode.AUDIO_ONLY
&& videoPlayMode != VideoMode.AUDIO_ONLY.code && videoMode != VideoMode.AUDIO_ONLY
&& media.getMediaType() == MediaType.VIDEO)
&& media.getMediaType() == MediaType.VIDEO))
context.startActivity(getPlayerActivityIntent(context, MediaType.VIDEO))
}
}
Expand Down Expand Up @@ -365,7 +366,6 @@ class StreamActionButton(item: Episode) : EpisodeActionButton(item) {
}

companion object {

fun stream(context: Context, media: Playable) {
if (media !is EpisodeMedia || !InTheatre.isCurMedia(media)) PlaybackService.clearCurTempSpeed()
PlaybackServiceStarter(context, media).shouldStreamThisTime(true).callEvenIfRunning(true).start()
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class MainActivity : CastEnabledActivity() {
}
}
override fun onSlide(view: View, slideOffset: Float) {
val audioPlayer = supportFragmentManager.findFragmentByTag(AudioPlayerFragment.TAG) as? AudioPlayerFragment ?: return
// val audioPlayer = supportFragmentManager.findFragmentByTag(AudioPlayerFragment.TAG) as? AudioPlayerFragment ?: return
// if (slideOffset == 0.0f) { //STATE_COLLAPSED
// audioPlayer.scrollToTop()
// }
audioPlayer.fadePlayerToToolbar(slideOffset)
// audioPlayer.fadePlayerToToolbar(slideOffset)
}
}

Expand Down Expand Up @@ -397,10 +397,10 @@ class MainActivity : CastEnabledActivity() {
navigationBarInsets.bottom + (if (visible) externalPlayerHeight else 0))
mainView.layoutParams = params
// val playerView = findViewById<FragmentContainerView>(R.id.playerFragment1)
val playerView = findViewById<ComposeView>(R.id.player1)
val playerParams = playerView?.layoutParams as? MarginLayoutParams
playerParams?.setMargins(navigationBarInsets.left, 0, navigationBarInsets.right, 0)
playerView?.layoutParams = playerParams
// val playerView = findViewById<ComposeView>(R.id.player1)
// val playerParams = playerView?.layoutParams as? MarginLayoutParams
// playerParams?.setMargins(navigationBarInsets.left, 0, navigationBarInsets.right, 0)
// playerView?.layoutParams = playerParams
audioPlayerView.visibility = if (visible) View.VISIBLE else View.GONE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ShareReceiverActivity : AppCompatActivity() {
if (finish) activity.finish()
}
// Youtube media
(isYoutubeURL(url) && url.path.startsWith("/watch")) || isYoutubeServiceURL(url) -> {
(isYoutubeURL(url) && (url.path.startsWith("/watch") || url.path.startsWith("/live"))) || isYoutubeServiceURL(url) -> {
if (log != null) upsertBlk(log) {it.type = "youtube media" }
Logd(TAG, "got youtube media")
mediaCB()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ class VideoplayerActivity : CastEnabledActivity() {
var vmCode = 0
if (curMedia is EpisodeMedia) {
val media_ = curMedia as EpisodeMedia
val vPol = media_.episode?.feed?.preferences?.videoModePolicy
if (vPol != null && vPol != VideoMode.NONE) vmCode = vPol.code
var vPol = media_.episode?.feed?.preferences?.videoModePolicy
if (vPol != null) {
if (vPol == VideoMode.AUDIO_ONLY && media_.forceVideo) vPol = VideoMode.WINDOW_VIEW
if (vPol != VideoMode.NONE) vmCode = vPol.code
}
}
Logd(TAG, "onCreate vmCode: $vmCode")
if (vmCode == 0) vmCode = videoPlayMode
Expand Down Expand Up @@ -290,6 +293,7 @@ class VideoplayerActivity : CastEnabledActivity() {
when (item.itemId) {
R.id.player_switch_to_audio_only -> {
switchToAudioOnly = true
(curMedia as? EpisodeMedia)?.forceVideo = false
finish()
return true
}
Expand Down Expand Up @@ -703,23 +707,23 @@ class VideoplayerActivity : CastEnabledActivity() {
lifecycleScope.launch {
try {
episode = withContext(Dispatchers.IO) {
var feedItem = (curMedia as? EpisodeMedia)?.episodeOrFetch()
if (feedItem != null) {
val duration = feedItem.media?.getDuration() ?: Int.MAX_VALUE
val url = feedItem.media?.downloadUrl
var episode_ = (curMedia as? EpisodeMedia)?.episodeOrFetch()
if (episode_ != null) {
val duration = episode_.media?.getDuration() ?: Int.MAX_VALUE
val url = episode_.media?.downloadUrl
val shownotesCleaner = ShownotesCleaner(requireContext())
if (url?.contains("youtube.com") == true && feedItem.description?.startsWith("Short:") == true) {
Logd(TAG, "getting extended description: ${feedItem.title}")
if (url?.contains("youtube.com") == true && episode_.description?.startsWith("Short:") == true) {
Logd(TAG, "getting extended description: ${episode_.title}")
try {
val info = feedItem.streamInfo
val info = episode_.streamInfo
if (info?.description?.content != null) {
feedItem = upsert(feedItem) { it.description = info.description?.content }
episode_ = upsert(episode_) { it.description = info.description?.content }
webviewData = shownotesCleaner.processShownotes(info.description!!.content, duration)
} else webviewData = shownotesCleaner.processShownotes(episode!!.description ?: "", duration)
} else webviewData = shownotesCleaner.processShownotes(episode_.description ?: "", duration)
} catch (e: Exception) { Logd(TAG, "StreamInfo error: ${e.message}") }
} else webviewData = shownotesCleaner.processShownotes(episode!!.description ?: "", duration)
} else webviewData = shownotesCleaner.processShownotes(episode_.description ?: "", duration)
}
feedItem
episode_
}
withContext(Dispatchers.Main) {
Logd(TAG, "load() item ${episode?.id}")
Expand Down Expand Up @@ -798,6 +802,7 @@ class VideoplayerActivity : CastEnabledActivity() {
binding.toggleViews.setOnClickListener { (activity as VideoplayerActivity).toggleViews() }
binding.audioOnly.setOnClickListener {
(activity as? VideoplayerActivity)?.switchToAudioOnly = true
(curMedia as? EpisodeMedia)?.forceVideo = false
(activity as? VideoplayerActivity)?.finish()
}
if (!itemsLoaded) webvDescription?.loadDataWithBaseURL("https://127.0.0.1", webviewData,
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/compose/EpisodesVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,14 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
if (index>=vms.size) return@LaunchedEffect
if (isDownloading()) vm.dlPercent = dls?.getProgress(vms[index].episode.media!!.downloadUrl!!) ?: 0
Logd(TAG, "LaunchedEffect $index downloadState: ${vms[index].downloadState} ${vm.episode.media?.downloaded} ${vm.dlPercent}")
vm.actionButton = EpisodeActionButton.forItem(vms[index].episode)
vm.actionButton = EpisodeActionButton.forItem(vm.episode)
vm.actionRes = vm.actionButton!!.getDrawable()
}
LaunchedEffect(key1 = status) {
if (index>=vms.size) return@LaunchedEffect
Logd(TAG, "LaunchedEffect $index isPlayingState: ${vms[index].isPlayingState} ${vms[index].episode.title}")
vm.actionButton = EpisodeActionButton.forItem(vms[index].episode)
vm.actionButton = EpisodeActionButton.forItem(vm.episode)
Logd(TAG, "LaunchedEffect vm.actionButton: ${vm.actionButton?.getLabel()}")
vm.actionRes = vm.actionButton!!.getDrawable()
}
// LaunchedEffect(vm.isPlayingState) {
Expand All @@ -696,7 +697,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
}
Box(modifier = Modifier.width(40.dp).height(40.dp).padding(end = 10.dp).align(Alignment.CenterVertically).pointerInput(Unit) {
detectTapGestures(onLongPress = { vm.showAltActionsDialog = true }, onTap = {
vm.actionButton?.onClick(activity)
vms[index].actionButton?.onClick(activity)
})
}, contentAlignment = Alignment.Center) {
// actionRes = actionButton.getDrawable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ class SleepTimerDialog : DialogFragment() {
paintDial.strokeWidth = size * 0.01f
val textPos = radToPoint(i / 24.0f * 360f, size / 2 - 2.5f * padding)
paintText.textSize = 0.4f * padding
canvas.drawText(i.toString(), textPos.x.toFloat(),
textPos.y + (-paintText.descent() - paintText.ascent()) / 2, paintText)
canvas.drawText(i.toString(), textPos.x.toFloat(), textPos.y + (-paintText.descent() - paintText.ascent()) / 2, paintText)
}
val outer = radToPoint(i / 24.0f * 360f, size / 2 - 1.7f * padding)
val inner = radToPoint(i / 24.0f * 360f, size / 2 - 1.9f * padding)
Expand Down
Loading

0 comments on commit a38d776

Please sign in to comment.