Merge branch 'libre-tube:master' into master

This commit is contained in:
ձռօռყ_սռĸռօառ 2022-06-17 19:30:55 +05:30 committed by GitHub
commit a76c3d04c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 3 deletions

View File

@ -10,8 +10,8 @@ android {
applicationId 'com.github.libretube'
minSdk 21
targetSdk 31
versionCode 11
versionName '0.3.1'
versionCode 12
versionName '0.3.2'
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
resValue "string", "app_name", "LibreTube"

View File

@ -53,6 +53,7 @@ import com.github.libretube.obj.Segment
import com.github.libretube.obj.Segments
import com.github.libretube.obj.Streams
import com.github.libretube.obj.Subscribe
import com.github.libretube.obj.StreamItem
import com.github.libretube.preferences.SponsorBlockSettings
import com.github.libretube.util.CronetHelper
import com.github.libretube.util.DescriptionAdapter
@ -101,6 +102,8 @@ class PlayerFragment : Fragment() {
private var eId: Int = 0
private var paused = false
private var whichQuality = 0
private var transitioning = false
private var autoplay = false
private var isZoomed: Boolean = false
private var isSubscribed: Boolean = false
@ -115,6 +118,7 @@ class PlayerFragment : Fragment() {
private lateinit var motionLayout: MotionLayout
private lateinit var exoPlayer: ExoPlayer
private lateinit var segmentData: Segments
private var relatedStreams: List<StreamItem>? = arrayListOf()
private var relatedStreamsEnabled = true
private lateinit var relDownloadVideo: LinearLayout
@ -386,10 +390,13 @@ class PlayerFragment : Fragment() {
uploader = response.uploader!!
thumbnailUrl = response.thumbnailUrl!!
// check whether related streams are enabled
// check whether related streams and autoplay are enabled
val sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(requireContext())
autoplay = sharedPreferences.getBoolean("autoplay", false)
relatedStreamsEnabled = sharedPreferences.getBoolean("related_streams_toggle", true)
// save related streams for autoplay
relatedStreams = response.relatedStreams
runOnUiThread {
createExoPlayer(view)
prepareExoPlayerView()
@ -515,8 +522,22 @@ class PlayerFragment : Fragment() {
!playWhenReady
)
// check if video has ended, next video is available and autoplay is enabled.
if (
playbackState == Player.STATE_ENDED &&
relatedStreams != null &&
relatedStreams!!.isNotEmpty() &&
!transitioning &&
autoplay
) {
transitioning = true
videoId = relatedStreams!![0].url!!.replace("/watch?v=", "")
fetchJsonAndInitPlayer(view)
}
if (playWhenReady && playbackState == Player.STATE_READY) {
// media actually playing
transitioning = false
view.findViewById<ImageView>(R.id.play_imageView)
.setImageResource(R.drawable.ic_pause)
} else if (playWhenReady) {

View File

@ -184,4 +184,5 @@
<string name="buffering_goal">Preloading</string>
<string name="buffering_goal_summary">Max. amount of seconds of video to buffer.</string>
<string name="playerVideoFormat">Video format for player</string>
<string name="player_autoplay">Autoplay</string>
</resources>

View File

@ -40,6 +40,13 @@
app:summary="@string/buffering_goal_summary"
app:title="@string/buffering_goal" />
<SwitchPreferenceCompat
android:icon="@drawable/ic_play"
app:key="autoplay"
app:title="@string/player_autoplay"
android:summaryOff="@string/disabled"
android:summaryOn="@string/enabled" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/downloads">

View File

@ -0,0 +1,9 @@
Subscribed Channels Rework
Update Checker
About Section in Settings
Live videos fix and indication
Comment replies
Search suggestions rewrite
Custom instance option
Video chapters support
Player notification thumbnail and description