use default video player instead of vlc

This commit is contained in:
Bnyro 2022-06-28 17:17:25 +02:00
parent e57ca95d47
commit 74811ac4d3

View File

@ -1,5 +1,6 @@
package com.github.libretube.fragments package com.github.libretube.fragments
import android.R.attr.mimeType
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.NotificationManager import android.app.NotificationManager
import android.app.PictureInPictureParams import android.app.PictureInPictureParams
@ -655,29 +656,28 @@ class PlayerFragment : Fragment() {
if (response.hls != null) { if (response.hls != null) {
view.findViewById<LinearLayout>(R.id.relPlayer_vlc).setOnClickListener { view.findViewById<LinearLayout>(R.id.relPlayer_vlc).setOnClickListener {
exoPlayer.pause() // start an intent with video as mimetype using the hls stream
try { val uri: Uri = Uri.parse(response.hls)
val vlcRequestCode = 42 val intent = Intent()
val uri: Uri = Uri.parse(response.hls)
val vlcIntent = Intent(Intent.ACTION_VIEW) intent.action = Intent.ACTION_VIEW
vlcIntent.setPackage("org.videolan.vlc") intent.setDataAndType(uri, "video/*")
vlcIntent.setDataAndTypeAndNormalize(uri, "video/*") intent.putExtra(Intent.EXTRA_TITLE, title)
vlcIntent.putExtra("title", response.title) intent.putExtra("title", title)
vlcIntent.putExtra("from_start", false) intent.putExtra("artist", uploader)
vlcIntent.putExtra("position", exoPlayer.currentPosition) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivityForResult(vlcIntent, vlcRequestCode)
} catch (e: Exception) { startActivity(intent)
Toast.makeText(context, R.string.vlcerror, Toast.LENGTH_SHORT)
.show()
}
} }
} }
if (relatedStreamsEnabled) { if (relatedStreamsEnabled) {
// only show related streams if enabled
relatedRecView.adapter = TrendingAdapter( relatedRecView.adapter = TrendingAdapter(
response.relatedStreams!!, response.relatedStreams!!,
childFragmentManager childFragmentManager
) )
} }
// set video description
val description = response.description!! val description = response.description!!
view.findViewById<TextView>(R.id.player_description).text = view.findViewById<TextView>(R.id.player_description).text =
// detect whether the description is html formatted // detect whether the description is html formatted