diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt index 11b8c940..f6c36e93 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt @@ -221,6 +221,7 @@ class CS3IPlayer : IPlayer { } override fun setExoplayerAudioTrack(trackLanguage: String?) { + preferredAudioTrackLanguage = trackLanguage exoPlayer?.trackSelectionParameters = exoPlayer?.trackSelectionParameters ?.buildUpon() ?.setPreferredAudioLanguage(trackLanguage) @@ -374,6 +375,12 @@ class CS3IPlayer : IPlayer { } companion object { + /** + * Fuck it, does not reset after player exit, people probably want that. + * It will default to the first audio track if the language does not exist anyways. + * // TODO using setKey? + **/ + private var preferredAudioTrackLanguage: String? = null private var simpleCache: SimpleCache? = null var requestSubtitleUpdate: (() -> Unit)? = null @@ -491,7 +498,11 @@ class CS3IPlayer : IPlayer { .setRendererDisabled(C.TRACK_TYPE_TEXT, true) .setTunnelingEnabled(true) .setDisabledTextTrackSelectionFlags(C.TRACK_TYPE_TEXT) - .clearSelectionOverrides() + .clearVideoSizeConstraints() + .setPreferredAudioLanguage(preferredAudioTrackLanguage) + + // This would also clear preferred audio +// .clearSelectionOverrides() .build() return trackSelector } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt index c309d36e..d05fc570 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt @@ -116,15 +116,15 @@ class M3u8Helper { return !url.contains("https://") && !url.contains("http://") } - suspend fun m3u8Generation(m3u8: M3u8Stream, returnThis: Boolean?): List { + suspend fun m3u8Generation(m3u8: M3u8Stream, returnThis: Boolean? = true): List { val list = mutableListOf() val m3u8Parent = getParentLink(m3u8.streamUrl) val response = app.get(m3u8.streamUrl, headers = m3u8.headers, verify = false).text - var hasAnyContent = false +// var hasAnyContent = false for (match in QUALITY_REGEX.findAll(response)) { - hasAnyContent = true +// hasAnyContent = true var (quality, m3u8Link, m3u8Link2) = match.destructured if (m3u8Link.isEmpty()) m3u8Link = m3u8Link2 if (absoluteExtensionDetermination(m3u8Link) == "m3u8") { @@ -141,16 +141,14 @@ class M3u8Helper { m3u8.headers ), false ) - } list += M3u8Stream( m3u8Link, quality.toIntOrNull(), m3u8.headers ) - } - if (returnThis ?: !hasAnyContent) { + if (returnThis != false) { list += M3u8Stream( m3u8.streamUrl, Qualities.Unknown.value, @@ -169,7 +167,10 @@ class M3u8Helper { val errored: Boolean = false ) - suspend fun hlsYield(qualities: List, startIndex: Int = 0): Iterator { + suspend fun hlsYield( + qualities: List, + startIndex: Int = 0 + ): Iterator { if (qualities.isEmpty()) return listOf( HlsDownloadData( byteArrayOf(), diff --git a/app/src/main/res/layout/fragment_player_tv.xml b/app/src/main/res/layout/fragment_player_tv.xml index f4cec44c..b84aaf7d 100644 --- a/app/src/main/res/layout/fragment_player_tv.xml +++ b/app/src/main/res/layout/fragment_player_tv.xml @@ -1,131 +1,131 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/player_background" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/black" + android:keepScreenOn="true" + android:orientation="horizontal" + android:screenOrientation="sensorLandscape" + app:backgroundTint="@android:color/black" + app:surface_type="texture_view"> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:show_timeout="0" /> + android:id="@+id/player_loading_overlay" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/black" + android:backgroundTint="@android:color/black" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + android:visibility="gone" + app:icon="@drawable/ic_baseline_skip_next_24" + tools:visibility="visible" /> + android:id="@+id/main_load" + android:layout_width="50dp" + android:layout_height="50dp" + android:layout_gravity="center" /> + android:id="@+id/video_go_back_holder_holder" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_margin="5dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_gravity="center" + android:src="@drawable/ic_baseline_arrow_back_24" + app:tint="@android:color/white" /> + android:layout_gravity="center" + android:background="@drawable/video_tap_button_always_white" + android:clickable="true" + android:focusable="true" + android:focusableInTouchMode="true" + android:nextFocusRight="@id/overlay_loading_skip_button" + android:nextFocusDown="@id/overlay_loading_skip_button" /> + + + android:layout_height="wrap_content" + android:layout_marginTop="15dp" + android:gravity="start" + android:textColor="@color/white" + android:textStyle="bold" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:text="78% at 18kb/s" /> - - + android:id="@+id/video_torrent_seeders" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="0dp" + android:gravity="start" + android:textColor="@color/white" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@+id/player_video_title" + tools:text="17 seeders" /> \ No newline at end of file diff --git a/app/src/main/res/layout/player_custom_layout_tv.xml b/app/src/main/res/layout/player_custom_layout_tv.xml index 1abfafed..405b606f 100644 --- a/app/src/main/res/layout/player_custom_layout_tv.xml +++ b/app/src/main/res/layout/player_custom_layout_tv.xml @@ -1,24 +1,24 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/player_holder" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:screenOrientation="landscape" + android:tag="television" + tools:orientation="vertical"> + android:id="@+id/subtitle_holder" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:id="@+id/shadow_overlay" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/player_gradient_tv" /> + android:id="@+id/player_video_holder" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="16dp"> + + + android:layout_height="wrap_content" + android:layout_marginStart="80dp" + android:layout_marginTop="20dp" + android:layout_marginEnd="32dp" + android:gravity="end" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="bold" + tools:text="Hello world" /> - - + android:id="@+id/player_video_title_rez" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="80dp" + android:layout_marginTop="40dp" + android:layout_marginEnd="32dp" + android:gravity="end" + android:textColor="@color/white" + android:textSize="16sp" + tools:text="1920x1080" /> + android:id="@+id/player_go_back_holder" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_margin="5dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_gravity="center" + android:contentDescription="@string/go_back_img_des" + android:src="@drawable/ic_baseline_arrow_back_24" + app:tint="@android:color/white" /> + android:id="@+id/player_go_back" + android:layout_width="70dp" + android:layout_height="70dp" + android:layout_gravity="center" + android:background="@drawable/video_tap_button_always_white" + android:clickable="true" + android:contentDescription="@string/go_back_img_des" + android:focusable="true" /> + android:indeterminate="true" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:visibility="visible" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:layout_marginBottom="20dp" + android:gravity="center" + android:orientation="horizontal" + android:paddingTop="4dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent"> + android:id="@id/exo_prev" + style="@style/ExoMediaButton.Previous" + android:tintMode="src_in" + app:tint="?attr/colorPrimaryDark" + tools:ignore="ContentDescription" /> + android:id="@id/exo_repeat_toggle" + style="@style/ExoMediaButton" + android:tintMode="src_in" + app:tint="?attr/colorPrimaryDark" + tools:ignore="ContentDescription" /> + android:id="@id/exo_next" + style="@style/ExoMediaButton.Next" + android:tintMode="src_in" + app:tint="?attr/colorPrimaryDark" + tools:ignore="ContentDescription" /> + android:id="@id/exo_vr" + style="@style/ExoMediaButton.VR" + android:tintMode="src_in" + app:tint="?attr/colorPrimaryDark" + tools:ignore="ContentDescription" /> + android:id="@id/exo_play" + android:layout_width="0dp" + android:layout_height="0dp" + android:tintMode="src_in" + app:tint="?attr/colorPrimaryDark" + tools:ignore="ContentDescription" /> + android:id="@id/exo_pause" + android:layout_width="0dp" + android:layout_height="0dp" + android:tintMode="src_in" + app:tint="?attr/colorPrimaryDark" + tools:ignore="ContentDescription" /> + android:id="@+id/bottom_player_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="64dp" + android:layout_marginEnd="64dp" + android:layout_marginBottom="10dp" + android:gravity="center_vertical" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent"> + android:id="@+id/player_video_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layoutDirection="ltr" + android:orientation="horizontal"> + android:src="@drawable/netflix_pause" + app:tint="@color/player_button_tv" + tools:ignore="ContentDescription" /> + android:id="@id/exo_position" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="end" + android:includeFontPadding="false" + android:minWidth="50dp" + android:paddingLeft="4dp" + android:paddingRight="4dp" + android:textColor="@android:color/white" + android:textSize="14sp" + android:textStyle="normal" + tools:text="15:30" /> + android:id="@id/exo_progress" + android:layout_width="0dp" + android:layout_height="30dp" + android:layout_gravity="center" + android:layout_weight="1" + android:focusable="false" + android:focusableInTouchMode="false" + app:bar_height="2dp" + app:played_color="?attr/colorPrimary" + app:scrubber_color="?attr/colorPrimary" + app:scrubber_dragged_size="26dp" + app:scrubber_enabled_size="24dp" + app:unplayed_color="@color/videoProgress" /> + android:id="@id/exo_duration" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginEnd="20dp" + android:includeFontPadding="false" + android:minWidth="50dp" + android:paddingLeft="4dp" + android:paddingRight="4dp" + android:textColor="@android:color/white" + android:textSize="14sp" + android:textStyle="normal" + tools:text="23:20" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center"> + android:id="@+id/player_lock_holder" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="horizontal"> + android:id="@+id/player_resize_btt" + style="@style/VideoButtonTV" + android:nextFocusLeft="@id/player_lock" + android:nextFocusRight="@id/player_speed_btt" + android:nextFocusUp="@id/player_pause_play" + android:text="@string/video_aspect_ratio_resize" + app:icon="@drawable/ic_baseline_aspect_ratio_24" /> + android:id="@+id/player_speed_btt" + style="@style/VideoButtonTV" + android:nextFocusLeft="@id/player_resize_btt" + android:nextFocusRight="@id/player_subtitle_offset_btt" + android:nextFocusUp="@id/player_pause_play" + app:icon="@drawable/ic_baseline_speed_24" + tools:text="Speed" /> + android:visibility="gone" + app:icon="@drawable/ic_outline_subtitles_24" + tools:visibility="visible" /> + android:id="@+id/player_sources_btt" + style="@style/VideoButtonTV" + android:nextFocusLeft="@id/player_subtitle_offset_btt" + android:nextFocusRight="@id/player_tracks_btt" + android:nextFocusUp="@id/player_pause_play" + android:text="@string/video_source" + app:icon="@drawable/ic_baseline_playlist_play_24" /> + android:id="@+id/player_tracks_btt" + style="@style/VideoButtonTV" + android:nextFocusLeft="@id/player_sources_btt" + android:nextFocusRight="@id/player_skip_op" + android:nextFocusUp="@id/player_pause_play" + android:text="@string/tracks" + app:icon="@drawable/ic_baseline_playlist_play_24" /> - android:nextFocusLeft="@id/player_skip_op" - android:nextFocusRight="@id/player_lock" - android:nextFocusUp="@id/player_pause_play" - android:text="@string/next_episode" - app:icon="@drawable/ic_baseline_skip_next_24" /> +