mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-25 02:14:32 +01:00
Added a Workaround for downloading and saving Audio Files.
Will improve on it soon! (Library needs Updation.)
This commit is contained in:
parent
8fcb22ab5d
commit
3d401744c0
@ -6,7 +6,7 @@ apply plugin: "androidx.navigation.safeargs.kotlin"
|
|||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 29
|
||||||
buildToolsVersion "30.0.0"
|
buildToolsVersion "30.0.0"
|
||||||
|
|
||||||
buildFeatures{
|
buildFeatures{
|
||||||
@ -17,7 +17,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'com.shabinder.musicforeveryone'
|
applicationId 'com.shabinder.musicforeveryone'
|
||||||
minSdkVersion 22
|
minSdkVersion 22
|
||||||
targetSdkVersion 30
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
android:requestLegacyExternalStorage="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
<activity android:name="com.shabinder.musicForEveryone.MainActivity">
|
<activity android:name="com.shabinder.musicForEveryone.MainActivity">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.shabinder.musicForEveryone.fragments
|
package com.shabinder.musicForEveryone.fragments
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -10,6 +11,8 @@ import androidx.databinding.DataBindingUtil
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import com.github.kiulian.downloader.model.formats.Format
|
||||||
|
import com.github.kiulian.downloader.model.quality.AudioQuality
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.shabinder.musicForEveryone.R
|
import com.shabinder.musicForEveryone.R
|
||||||
import com.shabinder.musicForEveryone.SharedViewModel
|
import com.shabinder.musicForEveryone.SharedViewModel
|
||||||
@ -17,6 +20,7 @@ import com.shabinder.musicForEveryone.bindImage
|
|||||||
import com.shabinder.musicForEveryone.databinding.MainFragmentBinding
|
import com.shabinder.musicForEveryone.databinding.MainFragmentBinding
|
||||||
import com.shabinder.musicForEveryone.utils.YoutubeConnector
|
import com.shabinder.musicForEveryone.utils.YoutubeConnector
|
||||||
import kaaes.spotify.webapi.android.SpotifyService
|
import kaaes.spotify.webapi.android.SpotifyService
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class MainFragment : Fragment() {
|
class MainFragment : Fragment() {
|
||||||
@ -103,6 +107,18 @@ class MainFragment : Fragment() {
|
|||||||
val ytDownloader = sharedViewModel.ytDownloader
|
val ytDownloader = sharedViewModel.ytDownloader
|
||||||
val video = ytDownloader?.getVideo(data.id)
|
val video = ytDownloader?.getVideo(data.id)
|
||||||
val details = video?.details()
|
val details = video?.details()
|
||||||
|
|
||||||
|
val outputDir = File(Environment.getExternalStorageDirectory().toString() + File.separator + "MyAudio")
|
||||||
|
val format:Format = video?.findAudioWithQuality(AudioQuality.low)?.get(0) as Format
|
||||||
|
val audioUrl = format.url()
|
||||||
|
if (audioUrl != null) {
|
||||||
|
Log.i("ytDownloader", audioUrl)
|
||||||
|
}else{Log.i("YT audio url is null", format.toString())}
|
||||||
|
|
||||||
|
val file:File = video.download( format , outputDir)
|
||||||
|
|
||||||
|
Log.i("YT File Path=> ", file.path)
|
||||||
|
|
||||||
Log.i("ytDownloader", details?.title()?:"Error")
|
Log.i("ytDownloader", details?.title()?:"Error")
|
||||||
binding.name.text = details?.title()
|
binding.name.text = details?.title()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user