Merge branch 'master' into master

This commit is contained in:
Bnyro 2022-06-17 16:51:54 +02:00 committed by GitHub
commit c1a4cbec6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 1 deletions

View File

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

View File

@ -189,4 +189,5 @@
<string name="audio">Audio</string> <string name="audio">Audio</string>
<string name="video">Video</string> <string name="video">Video</string>
<string name="downloading">Downloading</string> <string name="downloading">Downloading</string>
<string name="player_autoplay">Autoplay</string>
</resources> </resources>

View File

@ -40,6 +40,13 @@
app:summary="@string/buffering_goal_summary" app:summary="@string/buffering_goal_summary"
app:title="@string/buffering_goal" /> 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>
<PreferenceCategory app:title="@string/downloads"> <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