open in vlc

This commit is contained in:
rimthekid 2022-03-15 12:06:42 -04:00
parent 4b9f772b62
commit c22224d541
4 changed files with 51 additions and 6 deletions

View File

@ -3,12 +3,12 @@ package com.github.libretube
import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.app.ActivityManager
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
@ -19,19 +19,15 @@ import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat.getSystemService
import androidx.core.net.toUri
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.adapters.TrendingAdapter
@ -449,6 +445,24 @@ class PlayerFragment : Fragment() {
}else{
Toast.makeText(context,R.string.cannotDownload, Toast.LENGTH_SHORT).show()
}
if (response.hls!=null){
view.findViewById<RelativeLayout>(R.id.relPlayer_vlc).setOnClickListener {
exoPlayer.pause()
try{
val vlcRequestCode = 42
val uri: Uri = Uri.parse(response.hls)
val vlcIntent = Intent(Intent.ACTION_VIEW)
vlcIntent.setPackage("org.videolan.vlc")
vlcIntent.setDataAndTypeAndNormalize(uri, "video/*")
vlcIntent.putExtra("title", response.title)
vlcIntent.putExtra("from_start", false)
vlcIntent.putExtra("position", exoPlayer.currentPosition)
startActivityForResult(vlcIntent, vlcRequestCode)
}catch(e: Exception){
Toast.makeText(context, R.string.vlcerror, Toast.LENGTH_SHORT)
.show()
}
}}
}
}

View File

@ -0,0 +1,7 @@
<vector android:height="24dp" android:viewportHeight="1000"
android:viewportWidth="1000" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal">
<path android:fillColor="@android:color/white" android:pathData="M469.81,12.11c-5.14,0.79 -12.65,6.33 -17,11.86c-6.33,8.3 -23.33,56.15 -37.96,109.13c-5.14,17 77.1,28.47 134.84,18.98c42.31,-7.12 41.12,-4.75 25.7,-56.54c-19.38,-66.03 -25.7,-77.5 -43.1,-82.24C518.05,9.34 486.81,8.95 469.81,12.11z"/>
<path android:fillColor="@android:color/white" android:pathData="M356.72,328.83c-1.19,1.58 -13.05,40.73 -26.89,87.39l-24.91,84.62l16.61,14.63c40.33,35.99 154.6,52.99 253.85,37.56c60.89,-9.09 110.71,-30.45 116.64,-49.82c1.98,-5.93 -42.7,-170.42 -47.85,-177.14c-0.79,-0.79 -3.56,0.4 -6.32,2.77c-3.16,2.37 -18.58,7.91 -34.79,12.65c-62.87,18.19 -178.33,13.84 -228.15,-7.91C365.42,329.62 357.51,327.25 356.72,328.83z"/>
<path android:fillColor="@android:color/white" android:pathData="M185.51,628.94c-14.24,2.77 -19.77,12.65 -34.8,60.5C85.87,897.82 72.43,942.89 70.45,958.71c-3.95,34 -39.93,31.23 432.58,31.23c459.46,-0 428.23,1.98 428.23,-24.91c0,-6.72 -4.75,-27.29 -10.28,-45.87c-32.42,-107.95 -85.01,-274.81 -88.57,-280.74c-4.35,-8.31 -22.93,-12.26 -61.29,-12.26l-27.68,-0l1.19,24.12l1.58,24.12l-19.77,18.98c-35.19,33.61 -105.18,54.17 -200.47,58.12c-114.67,4.75 -219.06,-20.56 -257.41,-62.87c-13.44,-15.02 -13.84,-17 -12.65,-39.14l1.19,-23.33l-31.63,0.4C208.05,626.96 189.86,628.15 185.51,628.94z"/>
</vector>

View File

@ -52,7 +52,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4"
android:weightSum="5"
android:baselineAligned="false">
<RelativeLayout
@ -124,7 +124,29 @@
android:layout_centerHorizontal="true"
android:text="@string/download" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relPlayer_vlc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@+id/player_vlc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_vlc" />
<TextView
android:id="@+id/textVlc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/player_vlc"
android:layout_centerHorizontal="true"
android:text="@string/vlc" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -27,4 +27,6 @@
<string name="dlcomplete">Download is completed!</string>
<string name="dlisinprogress">Another Download is already in progress please wait till it\'s finished!</string>
<string name="downloadfailed">Download Failed!</string>
<string name="vlc">Open in VLC</string>
<string name="vlcerror">Can\'t open in VLC. Maybe it\'s not installed yet?</string>
</resources>