forked from recloudstream/cloudstream
watch quality
This commit is contained in:
parent
4016cba481
commit
142b800c7b
8 changed files with 122 additions and 42 deletions
|
@ -82,6 +82,7 @@ import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
|
|||
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.fromSaveToStyle
|
||||
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getAutoSelectLanguageISO639_1
|
||||
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getCurrentSavedStyle
|
||||
import com.lagradost.cloudstream3.utils.*
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.getFocusRequest
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.getVideoContentUri
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
|
||||
|
@ -92,9 +93,7 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey
|
|||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setLastWatched
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.getNavigationBarHeight
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
|
@ -102,8 +101,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
|
|||
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.showSystemUI
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||
import com.lagradost.cloudstream3.utils.VIDEO_PLAYER_BRIGHTNESS
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getId
|
||||
import kotlinx.android.synthetic.main.fragment_player.*
|
||||
import kotlinx.android.synthetic.main.player_custom_layout.*
|
||||
|
@ -351,21 +348,25 @@ class PlayerFragment : Fragment() {
|
|||
click_overlay?.isVisible = !isShowing
|
||||
|
||||
val titleMove = if (isShowing) 0f else -50.toPx.toFloat()
|
||||
ObjectAnimator.ofFloat(video_title, "translationY", titleMove).apply {
|
||||
video_title?.let {
|
||||
ObjectAnimator.ofFloat(it, "translationY", titleMove).apply {
|
||||
duration = 200
|
||||
start()
|
||||
}
|
||||
|
||||
ObjectAnimator.ofFloat(video_title_rez, "translationY", titleMove).apply {
|
||||
}
|
||||
video_title_rez?.let {
|
||||
ObjectAnimator.ofFloat(it, "translationY", titleMove).apply {
|
||||
duration = 200
|
||||
start()
|
||||
}
|
||||
|
||||
}
|
||||
val playerBarMove = if (isShowing) 0f else 50.toPx.toFloat()
|
||||
ObjectAnimator.ofFloat(bottom_player_bar, "translationY", playerBarMove).apply {
|
||||
bottom_player_bar?.let {
|
||||
ObjectAnimator.ofFloat(it, "translationY", playerBarMove).apply {
|
||||
duration = 200
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
changeSkip()
|
||||
val fadeTo = if (isShowing) 1f else 0f
|
||||
|
@ -398,8 +399,8 @@ class PlayerFragment : Fragment() {
|
|||
//player_pause_holder?.alpha = 0f
|
||||
}
|
||||
|
||||
bottom_player_bar.startAnimation(fadeAnimation)
|
||||
player_top_holder.startAnimation(fadeAnimation)
|
||||
bottom_player_bar?.startAnimation(fadeAnimation)
|
||||
player_top_holder?.startAnimation(fadeAnimation)
|
||||
// video_holder?.startAnimation(fadeAnimation)
|
||||
player_torrent_info?.isVisible = (isTorrent && isShowing)
|
||||
// player_torrent_info?.startAnimation(fadeAnimation)
|
||||
|
@ -1561,7 +1562,8 @@ class PlayerFragment : Fragment() {
|
|||
initPlayer()
|
||||
}
|
||||
|
||||
private fun setMirrorId(id: Int) {
|
||||
private fun setMirrorId(id: Int?) {
|
||||
if (id == null) return
|
||||
val copy = playerData.copy(mirrorId = id)
|
||||
playerData = copy
|
||||
//initPlayer()
|
||||
|
@ -1930,6 +1932,10 @@ class PlayerFragment : Fragment() {
|
|||
if (isDownloadedFile || currentUrl?.name == null) "${width}x${height}" else "${currentUrl.name} - ${width}x${height}"
|
||||
|
||||
if (!hasUsedFirstRender) { // DON'T WANT TO SET MULTIPLE MESSAGES
|
||||
if (!isDownloadedFile && !isTorrent && exoPlayer.duration in 5_000..10_000) {
|
||||
// if(getapi apiName )
|
||||
showToast(activity, R.string.vpn_might_be_needed, LENGTH_SHORT)
|
||||
}
|
||||
changeSkip()
|
||||
exoPlayer
|
||||
.createMessage { _, _ ->
|
||||
|
@ -2031,6 +2037,20 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
fun preferedQuality(tempCurrentUrls: List<ExtractorLink>?): Int? {
|
||||
if (tempCurrentUrls.isNullOrEmpty()) return null
|
||||
val sortedUrls = sortUrls(tempCurrentUrls).reversed()
|
||||
val currentQuality =
|
||||
settingsManager.getInt(getString(R.string.watch_quality_pref), Qualities.values().last().value)
|
||||
|
||||
var currentId = sortedUrls.first().getId() // lowest quality
|
||||
for (url in sortedUrls) {
|
||||
if (url.quality > currentQuality) break
|
||||
currentId = url.getId()
|
||||
}
|
||||
return currentId
|
||||
}
|
||||
|
||||
//http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initPlayer() {
|
||||
|
@ -2041,7 +2061,8 @@ class PlayerFragment : Fragment() {
|
|||
view?.setOnTouchListener { _, _ -> return@setOnTouchListener true } // VERY IMPORTANT https://stackoverflow.com/questions/28818926/prevent-clicking-on-a-button-in-an-activity-while-showing-a-fragment
|
||||
val tempCurrentUrls = getUrls()
|
||||
if (tempCurrentUrls != null) {
|
||||
setMirrorId(sortUrls(tempCurrentUrls).first().getId()) // BECAUSE URLS CANT BE REORDERED
|
||||
setMirrorId(preferedQuality(tempCurrentUrls))
|
||||
//setMirrorId(sortedUrls.first().getId()) // BECAUSE URLS CANT BE REORDERED
|
||||
}
|
||||
val tempUrl = getCurrentUrl()
|
||||
println("TEMP:" + tempUrl?.name)
|
||||
|
@ -2053,7 +2074,7 @@ class PlayerFragment : Fragment() {
|
|||
val currentUrls = getUrls()
|
||||
if (currentUrls != null && currentUrls.isNotEmpty()) {
|
||||
if (!isCurrentlyPlaying) {
|
||||
setMirrorId(sortUrls(currentUrls).first().getId()) // BECAUSE URLS CANT BE REORDERED
|
||||
setMirrorId(preferedQuality(currentUrls))
|
||||
initPlayer(getCurrentUrl())
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -11,13 +11,25 @@ import com.lagradost.cloudstream3.R
|
|||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
|
||||
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
||||
import com.lagradost.cloudstream3.utils.Qualities
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
var count = 0
|
||||
private var beneneCount = 0
|
||||
|
||||
private val languages = arrayListOf(
|
||||
Triple("\uD83C\uDDEC\uD83C\uDDE7", "English", "en"),
|
||||
Triple("\uD83C\uDDF3\uD83C\uDDF1", "Dutch", "nl"),
|
||||
Triple("\uD83C\uDDEB\uD83C\uDDF7", "French", "fr"),
|
||||
Triple("\uD83C\uDDEC\uD83C\uDDF7", "Greek", "gr"),
|
||||
Triple("\uD83C\uDDF8\uD83C\uDDEA", "Swedish", "sv"),
|
||||
Triple("\uD83C\uDDF5\uD83C\uDDED", "Tagalog", "tl"),
|
||||
) // idk, if you find a way of automating this it would be great
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
hideKeyboard()
|
||||
|
@ -25,21 +37,39 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val updatePreference = findPreference<Preference>(getString(R.string.manual_check_update_key))!!
|
||||
val localePreference = findPreference<Preference>(getString(R.string.locale_key))!!
|
||||
val benenePreference = findPreference<Preference>(getString(R.string.benene_count))!!
|
||||
val watchQualityPreference = findPreference<Preference>(getString(R.string.quality_pref_key))!!
|
||||
|
||||
watchQualityPreference.setOnPreferenceClickListener {
|
||||
val prefNames = resources.getStringArray(R.array.quality_pref)
|
||||
val prefValues = resources.getIntArray(R.array.quality_pref_values)
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
val currentQuality = settingsManager.getInt(getString(R.string.watch_quality_pref), Qualities.values().last().value)
|
||||
context?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentQuality),
|
||||
getString(R.string.watch_quality_pref),
|
||||
true,
|
||||
{}) {
|
||||
settingsManager.edit().putInt(getString(R.string.watch_quality_pref), prefValues[it]).apply()
|
||||
}
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
try {
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
count = settingsManager.getInt(getString(R.string.benene_count), 0)
|
||||
beneneCount = settingsManager.getInt(getString(R.string.benene_count), 0)
|
||||
|
||||
benenePreference.summary =
|
||||
if (count <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(
|
||||
count
|
||||
if (beneneCount <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(
|
||||
beneneCount
|
||||
)
|
||||
benenePreference.setOnPreferenceClickListener {
|
||||
try {
|
||||
count++
|
||||
settingsManager.edit().putInt(getString(R.string.benene_count), count).apply()
|
||||
it.summary = getString(R.string.benene_count_text).format(count)
|
||||
beneneCount++
|
||||
settingsManager.edit().putInt(getString(R.string.benene_count), beneneCount).apply()
|
||||
it.summary = getString(R.string.benene_count_text).format(beneneCount)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
@ -62,20 +92,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
localePreference.setOnPreferenceClickListener { pref ->
|
||||
val languages = arrayListOf(
|
||||
Triple("\uD83C\uDDEC\uD83C\uDDE7", "English", "en"),
|
||||
Triple("\uD83C\uDDF3\uD83C\uDDF1", "Dutch", "nl"),
|
||||
Triple("\uD83C\uDDEB\uD83C\uDDF7", "French", "fr"),
|
||||
Triple("\uD83C\uDDEC\uD83C\uDDF7", "Greek", "gr"),
|
||||
Triple("\uD83C\uDDF8\uD83C\uDDEA", "Swedish", "sv"),
|
||||
Triple("\uD83C\uDDF5\uD83C\uDDED", "Tagalog", "tl"),
|
||||
) // idk, if you find a way of automating this it would be great
|
||||
if (count > 100) {
|
||||
languages.add(Triple("\uD83E\uDD8D", "mmmm... monke", "mo"))
|
||||
val tempLangs = languages
|
||||
if (beneneCount > 100) {
|
||||
tempLangs.add(Triple("\uD83E\uDD8D", "mmmm... monke", "mo"))
|
||||
}
|
||||
val current = getCurrentLocale()
|
||||
val languageCodes = languages.map { it.third }
|
||||
val languageNames = languages.map { "${it.first} ${it.second}" }
|
||||
val languageCodes = tempLangs.map { it.third }
|
||||
val languageNames = tempLangs.map { "${it.first} ${it.second}" }
|
||||
val index = languageCodes.indexOf(current)
|
||||
pref?.context?.showDialog(
|
||||
languageNames, index, getString(R.string.app_language), true, { }
|
||||
|
@ -104,7 +127,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||
if (preference != null) {
|
||||
if (preference.key == "subtitle_settings_key") {
|
||||
if (preference.key == getString(R.string.subtitle_settings_key)) {
|
||||
SubtitlesFragment.push(activity, false)
|
||||
}
|
||||
}
|
||||
|
|
5
app/src/main/res/drawable/ic_baseline_hd_24.xml
Normal file
5
app/src/main/res/drawable/ic_baseline_hd_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM11,15L9.5,15v-2h-2v2L6,15L6,9h1.5v2.5h2L9.5,9L11,9v6zM13,9h4c0.55,0 1,0.45 1,1v4c0,0.55 -0.45,1 -1,1h-4L13,9zM14.5,13.5h2v-3h-2v3z"/>
|
||||
</vector>
|
|
@ -313,6 +313,8 @@
|
|||
android:layout_height="wrap_content">
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/WhiteButton"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:visibility="visible"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/result_play_movie"
|
||||
|
@ -323,6 +325,8 @@
|
|||
</com.google.android.material.button.MaterialButton>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/BlackButton"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:visibility="visible"
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="Downloading"
|
||||
|
|
|
@ -202,4 +202,6 @@
|
|||
<string name="pause">Pausa</string>
|
||||
<string name="resume">Återuppta</string>
|
||||
<string name="storage_error">Ett nerladdningsfel uppstod, kolla om appen har lagringsbehörigheter</string>
|
||||
<string name="watch_quality_pref">Föredragen videokvalitet</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -14,6 +14,23 @@
|
|||
<item>@id/cast_button_type_forward_30_seconds</item>
|
||||
</array>
|
||||
|
||||
<array name="quality_pref">
|
||||
<item>2160p</item>
|
||||
<item>1440p</item>
|
||||
<item>1080p</item>
|
||||
<item>720p</item>
|
||||
<item>480p</item>
|
||||
<item>360p</item>
|
||||
</array>
|
||||
<array name="quality_pref_values">
|
||||
<item>4</item>
|
||||
<item>3</item>
|
||||
<item>2</item>
|
||||
<item>1</item>
|
||||
<item>-1</item>
|
||||
<item>-2</item>
|
||||
</array>
|
||||
|
||||
<array name="episode_long_click_options">
|
||||
<item>@string/episode_action_chomecast_episode</item>
|
||||
<item>@string/episode_action_chomecast_mirror</item>
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<string name="manual_check_update_key" translatable="false">manual_check_update</string>
|
||||
<string name="fast_forward_button_time_key" translatable="false">fast_forward_button_time</string>
|
||||
<string name="benene_count" translatable="false">benene_count</string>
|
||||
<string name="subtitle_settings_key" translatable="false">subtitle_settings_key</string>
|
||||
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
||||
|
||||
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
|
||||
<string name="extra_info_format" translatable="false" formatted="true">%d %s | %sMB</string>
|
||||
|
@ -240,4 +242,5 @@
|
|||
|
||||
<string name="dont_show_again">Don\'t show again</string>
|
||||
<string name="update">Update</string>
|
||||
<string name="watch_quality_pref">Preferred watch quality</string>
|
||||
</resources>
|
||||
|
|
|
@ -8,11 +8,16 @@
|
|||
app:isPreferenceVisible="true"
|
||||
>
|
||||
<Preference
|
||||
android:key="subtitle_settings_key"
|
||||
android:key="@string/subtitle_settings_key"
|
||||
android:title="@string/player_subtitles_settings"
|
||||
android:icon="@drawable/ic_outline_subtitles_24"
|
||||
app:summary="@string/player_subtitles_settings_des">
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="@string/quality_pref_key"
|
||||
android:title="@string/watch_quality_pref"
|
||||
android:icon="@drawable/ic_baseline_hd_24">
|
||||
</Preference>
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_picture_in_picture_alt_24"
|
||||
app:key="pip_enabled"
|
||||
|
|
Loading…
Reference in a new issue