This commit is contained in:
LagradOst 2021-06-11 15:33:30 +02:00
parent a102d5f66d
commit ac442edd4e
9 changed files with 100 additions and 23 deletions

View file

@ -70,7 +70,7 @@ class SelectSourceController(val view: ImageView) : UIController() {
super.onMediaStatusUpdated()
// If there's 1 item it won't show
val dataString = remoteMediaClient.mediaQueue.getItemAtIndex(1)?.media?.customData?.get("data") as? String
println("TEXT: " + dataString)
view.visibility = if (dataString != null) VISIBLE else INVISIBLE
}

View file

@ -30,6 +30,7 @@ import android.widget.Toast
import android.widget.Toast.LENGTH_SHORT
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.preference.PreferenceManager
@ -215,7 +216,7 @@ class PlayerFragment : Fragment() {
if (ctx.isShowing && !ctx.isLocked && ctx.doubleTapEnabled) {
uiScope.launch {
delay(doubleClickQualificationSpanInMillis)
delay(doubleClickQualificationSpanInMillis + 1)
check()
}
} else {
@ -511,8 +512,10 @@ class PlayerFragment : Fragment() {
val alphaAnimation = AlphaAnimation(0f, 1f)
alphaAnimation.duration = 100
alphaAnimation.fillAfter = true
loading_overlay.startAnimation(alphaAnimation)
video_go_back_holder.visibility = VISIBLE
overlay_loading_skip_button.visibility = VISIBLE
loading_overlay.startAnimation(alphaAnimation)
if (this::exoPlayer.isInitialized) {
isPlayerPlaying = exoPlayer.playWhenReady
playbackPosition = exoPlayer.currentPosition
@ -812,8 +815,20 @@ class PlayerFragment : Fragment() {
}
}
overlay_loading_skip_button?.alpha = 0.5f
observeDirectly(viewModel.allEpisodes) { _allEpisodes ->
allEpisodes = _allEpisodes
val current = getUrls()
if (current != null) {
if (current.isNotEmpty()) {
overlay_loading_skip_button?.alpha = 1f
} else {
overlay_loading_skip_button?.alpha = 0.5f
}
} else {
overlay_loading_skip_button?.alpha = 0.5f
}
}
observeDirectly(viewModel.resultResponse) { data ->
@ -880,6 +895,13 @@ class PlayerFragment : Fragment() {
ffwrd()
}
overlay_loading_skip_button.setOnClickListener {
setMirrorId(sortUrls(getUrls() ?: return@setOnClickListener).first()
.getId()) // BECAUSE URLS CANT BE REORDERED
if (!isCurrentlyPlaying) {
initPlayer(getCurrentUrl())
}
}
lock_player.setOnClickListener {
isLocked = !isLocked
@ -1105,7 +1127,7 @@ class PlayerFragment : Fragment() {
private fun setMirrorId(id: Int) {
val copy = playerData.copy(mirrorId = id)
playerData = copy
initPlayer()
//initPlayer()
}
override fun onStart() {
@ -1196,6 +1218,7 @@ class PlayerFragment : Fragment() {
@SuppressLint("SetTextI18n")
fun initPlayer(currentUrl: ExtractorLink?) {
if (currentUrl == null) return
isCurrentlyPlaying = true
hasUsedFirstRender = false
try {
@ -1268,8 +1291,18 @@ class PlayerFragment : Fragment() {
val alphaAnimation = AlphaAnimation(1f, 0f)
alphaAnimation.duration = 300
alphaAnimation.fillAfter = true
alphaAnimation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {}
override fun onAnimationRepeat(animation: Animation?) {}
override fun onAnimationEnd(animation: Animation?) {
loading_overlay.post { video_go_back_holder.visibility = GONE; }
}
})
overlay_loading_skip_button.visibility = GONE
loading_overlay.startAnimation(alphaAnimation)
video_go_back_holder.visibility = GONE
exoPlayer.setHandleAudioBecomingNoisy(true) // WHEN HEADPHONES ARE PLUGGED OUT https://github.com/google/ExoPlayer/issues/7288
player_view.player = exoPlayer
@ -1318,7 +1351,7 @@ class PlayerFragment : Fragment() {
println("FIRST RENDER")
changeSkip()
exoPlayer
.createMessage { messageType, payload ->
.createMessage { _, _ ->
changeSkip()
}
.setLooper(Looper.getMainLooper())
@ -1327,7 +1360,7 @@ class PlayerFragment : Fragment() {
.setDeleteAfterDelivery(false)
.send()
exoPlayer
.createMessage { messageType, payload ->
.createMessage { _, _ ->
changeSkip()
}
.setLooper(Looper.getMainLooper())
@ -1411,9 +1444,12 @@ class PlayerFragment : Fragment() {
//http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
@SuppressLint("SetTextI18n")
private fun initPlayer() {
isCurrentlyPlaying = true
println("INIT PLAYER")
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
}
val tempUrl = getCurrentUrl()
println("TEMP:" + tempUrl?.name)
if (tempUrl == null) {
@ -1423,9 +1459,13 @@ class PlayerFragment : Fragment() {
//if(it is Resource.Success && it.value == true)
val currentUrls = getUrls()
if (currentUrls != null && currentUrls.isNotEmpty()) {
setMirrorId(sortUrls(currentUrls)[0].getId()) // BECAUSE URLS CANT BE REORDERED
if (!isCurrentlyPlaying) {
setMirrorId(sortUrls(currentUrls).first().getId()) // BECAUSE URLS CANT BE REORDERED
initPlayer(getCurrentUrl())
}
} else {
Toast.makeText(context, "No Links Found", Toast.LENGTH_SHORT).show()
}
initPlayer(getCurrentUrl())
}
}
} else {

View file

@ -120,14 +120,15 @@ class ResultViewModel : ViewModel() {
}
val links = ArrayList<ExtractorLink>()
val localData = safeApiCall {
getApiFromName(_apiName.value).loadLinks(data, isCasting) { //TODO IMPLEMENT CASTING
getApiFromName(_apiName.value).loadLinks(data, isCasting) {
for (i in links) {
if (i.url == it.url) return@loadLinks
}
println("LINK ADDED::::: " + it.url)
links.add(it)
_allEpisodes.value?.set(id, links)
_allEpisodes.postValue(_allEpisodes.value)
// _allEpisodes.value?.get(episode.id)?.add(it)
}
links

View file

@ -2,6 +2,7 @@ package com.lagradost.cloudstream3.utils
import android.content.Context
import com.google.android.gms.cast.CastMediaControlIntent
import com.google.android.gms.cast.LaunchOptions
import com.google.android.gms.cast.framework.CastOptions
import com.google.android.gms.cast.framework.OptionsProvider
import com.google.android.gms.cast.framework.SessionProvider
@ -13,14 +14,14 @@ import com.lagradost.cloudstream3.ui.ControllerActivity
import java.util.*
class CastOptionsProvider : OptionsProvider {
override fun getCastOptions(p0: Context?): CastOptions {
override fun getCastOptions(context: Context): CastOptions {
val buttonActions = listOf(
MediaIntentReceiver.ACTION_REWIND,
MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK,
MediaIntentReceiver.ACTION_FORWARD,
MediaIntentReceiver.ACTION_STOP_CASTING
)
val compatButtonAction = intArrayOf(1,3)
val compatButtonAction = intArrayOf(1, 3)
val notificationOptions =
NotificationOptions.Builder()
.setTargetActivityClassName(ControllerActivity::class.qualifiedName)
@ -36,7 +37,8 @@ class CastOptionsProvider : OptionsProvider {
.build()
return CastOptions.Builder()
.setReceiverApplicationId( CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
//.setReceiverApplicationId("C0868879") // C0868879 = SAMPLE, CHANGE TO A NICE ID at https://developers.google.com/cast/docs/registration
.setStopReceiverApplicationWhenEndingSession(true)
.setCastMediaOptions(mediaOptions)
.build()

View 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="M6,18l8.5,-6L6,6v12zM16,6v12h2V6h-2z"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="?attr/white"
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.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98 0,-0.34 -0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.09,-0.16 -0.26,-0.25 -0.44,-0.25 -0.06,0 -0.12,0.01 -0.17,0.03l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.06,-0.02 -0.12,-0.03 -0.18,-0.03 -0.17,0 -0.34,0.09 -0.43,0.25l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98 0,0.33 0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.09,0.16 0.26,0.25 0.44,0.25 0.06,0 0.12,-0.01 0.17,-0.03l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.06,0.02 0.12,0.03 0.18,0.03 0.17,0 0.34,-0.09 0.43,-0.25l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM17.45,11.27c0.04,0.31 0.05,0.52 0.05,0.73 0,0.21 -0.02,0.43 -0.05,0.73l-0.14,1.13 0.89,0.7 1.08,0.84 -0.7,1.21 -1.27,-0.51 -1.04,-0.42 -0.9,0.68c-0.43,0.32 -0.84,0.56 -1.25,0.73l-1.06,0.43 -0.16,1.13 -0.2,1.35h-1.4l-0.19,-1.35 -0.16,-1.13 -1.06,-0.43c-0.43,-0.18 -0.83,-0.41 -1.23,-0.71l-0.91,-0.7 -1.06,0.43 -1.27,0.51 -0.7,-1.21 1.08,-0.84 0.89,-0.7 -0.14,-1.13c-0.03,-0.31 -0.05,-0.54 -0.05,-0.74s0.02,-0.43 0.05,-0.73l0.14,-1.13 -0.89,-0.7 -1.08,-0.84 0.7,-1.21 1.27,0.51 1.04,0.42 0.9,-0.68c0.43,-0.32 0.84,-0.56 1.25,-0.73l1.06,-0.43 0.16,-1.13 0.2,-1.35h1.39l0.19,1.35 0.16,1.13 1.06,0.43c0.43,0.18 0.83,0.41 1.23,0.71l0.91,0.7 1.06,-0.43 1.27,-0.51 0.7,1.21 -1.07,0.85 -0.89,0.7 0.14,1.13zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

View file

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:keepScreenOn="true"
app:backgroundTint="@android:color/black"
@ -26,6 +26,8 @@
app:layout_constraintTop_toTopOf="parent"
app:controller_layout_id="@layout/player_custom_layout"
/>
<FrameLayout
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@ -38,6 +40,26 @@
android:backgroundTint="@android:color/black"
>
<com.google.android.material.button.MaterialButton
android:visibility="visible"
android:layout_marginTop="70dp"
android:layout_gravity="center"
app:cornerRadius="4dp"
android:id="@+id/overlay_loading_skip_button"
android:text="@string/skip_loading"
app:rippleColor="?attr/colorPrimary"
android:textColor="?attr/textColor"
app:iconTint="?attr/textColor"
android:textAllCaps="false"
app:icon="@drawable/ic_baseline_skip_next_24"
android:backgroundTint="@color/transparent"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="45dp">
</com.google.android.material.button.MaterialButton>
<ProgressBar
android:layout_width="50dp"
android:layout_height="50dp"
@ -45,9 +67,10 @@
android:id="@+id/main_load"
>
</ProgressBar>
<FrameLayout
android:layout_margin="5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -57,17 +80,17 @@
android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_arrow_back_24"
android:contentDescription="@string/go_back">
app:tint="@android:color/white"
>
</ImageView>
<ImageView
android:id="@+id/video_go_back_holder"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
android:focusable="true"
android:clickable="true"
android:background="@drawable/video_tap_button"
android:contentDescription="@string/go_back">
android:background="@drawable/video_tap_button_always_white">
</ImageView>
</FrameLayout>
</FrameLayout>

View file

@ -17,7 +17,7 @@
android:title="@string/title_downloads"/>
<item
android:id="@+id/navigation_settings"
android:icon="@drawable/netflix_download"
android:icon="@drawable/ic_outline_settings_24"
android:title="@string/title_settings"/>
</menu>

View file

@ -21,4 +21,5 @@
<string name="result_tags">Genres</string>
<string name="result_share">Share</string>
<string name="result_open_in_browser">Open In Browser</string>
<string name="skip_loading">Skip Loading</string>
</resources>