[Android] ContextSheet: fix set as ringtone

Duncan McNamara git at videolan.org
Fri May 20 05:24:07 UTC 2022


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Wed May 18 16:09:36 2022 +0200| [9d2d55e7d97275bef75d80885d090bf9873ccaf2] | committer: Nicolas Pomepuy

ContextSheet: fix set as ringtone

Fixes #2531

> https://code.videolan.org/videolan/vlc-android/commit/9d2d55e7d97275bef75d80885d090bf9873ccaf2
---

 .../vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.kt       | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.kt
index 7f0706cf8..36fadb104 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.kt
@@ -28,6 +28,7 @@ import android.net.Uri
 import android.os.Build
 import android.provider.MediaStore
 import android.util.Log
+import android.webkit.MimeTypeMap
 import android.widget.Toast
 import androidx.annotation.WorkerThread
 import androidx.core.content.contentValuesOf
@@ -68,9 +69,12 @@ object AudioUtil {
                 return at snackerConfirm
             }
 
+            val type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
+                MimeTypeMap.getFileExtensionFromUrl(song.uri.path))
+
             val values = contentValuesOf(
                     MediaStore.MediaColumns.TITLE to song.title,
-                    MediaStore.MediaColumns.MIME_TYPE to "audio/*",
+                    MediaStore.MediaColumns.MIME_TYPE to type,
                     MediaStore.Audio.Media.ARTIST to song.artist,
                     MediaStore.Audio.Media.IS_RINGTONE to true,
                     MediaStore.Audio.Media.IS_NOTIFICATION to false,



More information about the Android mailing list