mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fix
This commit is contained in:
parent
c60852794f
commit
bb9ab80d8a
3 changed files with 20 additions and 25 deletions
|
@ -98,6 +98,7 @@ object DownloadButtonSetup {
|
||||||
R.id.global_to_navigation_player, PlayerFragment.newInstance(
|
R.id.global_to_navigation_player, PlayerFragment.newInstance(
|
||||||
UriData(
|
UriData(
|
||||||
info.path.toString(),
|
info.path.toString(),
|
||||||
|
keyInfo.basePath,
|
||||||
keyInfo.relativePath,
|
keyInfo.relativePath,
|
||||||
keyInfo.displayName,
|
keyInfo.displayName,
|
||||||
click.data.parentId,
|
click.data.parentId,
|
||||||
|
|
|
@ -78,7 +78,6 @@ import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getAu
|
||||||
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getCurrentSavedStyle
|
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getCurrentSavedStyle
|
||||||
import com.lagradost.cloudstream3.utils.*
|
import com.lagradost.cloudstream3.utils.*
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.getFocusRequest
|
import com.lagradost.cloudstream3.utils.AppUtils.getFocusRequest
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.getVideoContentUri
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
|
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.onAudioFocusEvent
|
import com.lagradost.cloudstream3.utils.AppUtils.onAudioFocusEvent
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.requestLocalAudioFocus
|
import com.lagradost.cloudstream3.utils.AppUtils.requestLocalAudioFocus
|
||||||
|
@ -108,6 +107,7 @@ import kotlin.math.abs
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
|
|
||||||
//http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
|
//http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
|
||||||
const val STATE_RESUME_WINDOW = "resumeWindow"
|
const val STATE_RESUME_WINDOW = "resumeWindow"
|
||||||
const val STATE_RESUME_POSITION = "resumePosition"
|
const val STATE_RESUME_POSITION = "resumePosition"
|
||||||
|
@ -158,6 +158,7 @@ data class PlayerData(
|
||||||
|
|
||||||
data class UriData(
|
data class UriData(
|
||||||
val uri: String,
|
val uri: String,
|
||||||
|
val basePath: String?,
|
||||||
val relativePath: String,
|
val relativePath: String,
|
||||||
val displayName: String,
|
val displayName: String,
|
||||||
val parentId: Int?,
|
val parentId: Int?,
|
||||||
|
@ -1608,7 +1609,7 @@ class PlayerFragment : Fragment() {
|
||||||
if (isDownloadedFile) {
|
if (isDownloadedFile) {
|
||||||
if (!supportsDownloadedFiles) return null
|
if (!supportsDownloadedFiles) return null
|
||||||
val list = ArrayList<SubtitleFile>()
|
val list = ArrayList<SubtitleFile>()
|
||||||
VideoDownloadManager.getFolder(this, uriData.relativePath)?.forEach { file ->
|
VideoDownloadManager.getFolder(this, uriData.relativePath, uriData.basePath)?.forEach { file ->
|
||||||
val name = uriData.displayName.removeSuffix(".mp4")
|
val name = uriData.displayName.removeSuffix(".mp4")
|
||||||
if (file.first != uriData.displayName && file.first.startsWith(name)) {
|
if (file.first != uriData.displayName && file.first.startsWith(name)) {
|
||||||
val realName = file.first.removePrefix(name)
|
val realName = file.first.removePrefix(name)
|
||||||
|
@ -1882,15 +1883,7 @@ class PlayerFragment : Fragment() {
|
||||||
mediaItemBuilder.setUri(currentUrl.url)
|
mediaItemBuilder.setUri(currentUrl.url)
|
||||||
} else if (trueUri != null || uri != null) {
|
} else if (trueUri != null || uri != null) {
|
||||||
val uriPrimary = trueUri ?: Uri.parse(uri)
|
val uriPrimary = trueUri ?: Uri.parse(uri)
|
||||||
if (uriPrimary.scheme == "content") {
|
|
||||||
mediaItemBuilder.setUri(uriPrimary)
|
mediaItemBuilder.setUri(uriPrimary)
|
||||||
// video_title?.text = uriPrimary.toString()
|
|
||||||
} else {
|
|
||||||
//mediaItemBuilder.setUri(Uri.parse(currentUrl.url))
|
|
||||||
val realUri = trueUri ?: getVideoContentUri(requireContext(), uri ?: uriPrimary.path ?: "")
|
|
||||||
// video_title?.text = uri.toString()
|
|
||||||
mediaItemBuilder.setUri(realUri)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val subs = context?.getSubs() ?: emptyList()
|
val subs = context?.getSubs() ?: emptyList()
|
||||||
|
@ -1913,7 +1906,7 @@ class PlayerFragment : Fragment() {
|
||||||
activeSubtitles = subItemsId
|
activeSubtitles = subItemsId
|
||||||
mediaItemBuilder.setSubtitles(subItems)
|
mediaItemBuilder.setSubtitles(subItems)
|
||||||
|
|
||||||
//might add https://github.com/ed828a/Aihua/blob/1896f46888b5a954b367e83f40b845ce174a2328/app/src/main/java/com/dew/aihua/player/playerUI/VideoPlayer.kt#L287 toggle caps
|
//might add https://github.com/ed828a/Aihua/blob/1896f46888b5a954b367e83f40b845ce174a2328/app/src/main/java/com/dew/aihua/player/playerUI/VideoPlayer.kt#L287 toggle caps
|
||||||
|
|
||||||
val mediaItem = mediaItemBuilder.build()
|
val mediaItem = mediaItemBuilder.build()
|
||||||
val trackSelector = DefaultTrackSelector(requireContext())
|
val trackSelector = DefaultTrackSelector(requireContext())
|
||||||
|
@ -2214,7 +2207,8 @@ class PlayerFragment : Fragment() {
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun initPlayer() {
|
private fun initPlayer() {
|
||||||
if (isDownloadedFile) {
|
if (isDownloadedFile) {
|
||||||
initPlayer(null, uriData.uri.removePrefix("file://").replace("%20", " ")) // FIX FILE PERMISSION
|
//.removePrefix("file://").replace("%20", " ") // FIX FILE PERMISSION
|
||||||
|
initPlayer(null, uriData.uri)
|
||||||
}
|
}
|
||||||
println("INIT PLAYER")
|
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
|
view?.setOnTouchListener { _, _ -> return@setOnTouchListener true } // VERY IMPORTANT https://stackoverflow.com/questions/28818926/prevent-clicking-on-a-button-in-an-activity-while-showing-a-fragment
|
||||||
|
|
|
@ -5,13 +5,11 @@ import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.*
|
import android.content.*
|
||||||
import android.database.Cursor
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.provider.OpenableColumns
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
@ -23,7 +21,6 @@ import androidx.work.ExistingWorkPolicy
|
||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.google.android.exoplayer2.util.UriUtil
|
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import com.lagradost.cloudstream3.MainActivity
|
import com.lagradost.cloudstream3.MainActivity
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
|
@ -39,7 +36,10 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import okhttp3.internal.closeQuietly
|
import okhttp3.internal.closeQuietly
|
||||||
import java.io.*
|
import java.io.BufferedInputStream
|
||||||
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.io.OutputStream
|
||||||
import java.lang.Thread.sleep
|
import java.lang.Thread.sleep
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
@ -450,8 +450,8 @@ object VideoDownloadManager {
|
||||||
* Used for getting video player subs.
|
* Used for getting video player subs.
|
||||||
* @return List of pairs for the files in this format: <Name, Uri>
|
* @return List of pairs for the files in this format: <Name, Uri>
|
||||||
* */
|
* */
|
||||||
fun getFolder(context: Context, relativePath: String): List<Pair<String, Uri>>? {
|
fun getFolder(context: Context, relativePath: String, basePath: String?): List<Pair<String, Uri>>? {
|
||||||
val base = context.getBasePath().first
|
val base = basePathToFile(context, basePath)
|
||||||
val folder = base?.gotoDir(relativePath, false)
|
val folder = base?.gotoDir(relativePath, false)
|
||||||
|
|
||||||
if (isScopedStorage && base.isDownloadDir()) {
|
if (isScopedStorage && base.isDownloadDir()) {
|
||||||
|
|
Loading…
Reference in a new issue