mpv-android / mpv-android

#mpv-android @ libera.chat
MIT License
1.81k stars 226 forks source link

Add All File Access Permission #889

Open sujitfg1 opened 1 month ago

sujitfg1 commented 1 month ago

Atleast add file access permission so MPV can access file, script or Lua we assign.

With just Photos and videos permission it fail to read other files.

Bonboon229 commented 1 month ago

Can confirm this issue exists.

MartinEesmaa commented 1 month ago

Hello @sujitfg1 and @Bonboon229.

I fixed the bug and for this issue by allowing and showing permission of Files and media for full access of all files since Android 13, older than Android 13 is fine without bug.

You can have look my commit: https://github.com/MartinEesmaa/mpv-android-vvc/commit/100ea0db0f5268fbec6bac56479f8102a3dd3dd3

When you running since Android 13 and you want to open latest mpv android app with file picker (legacy), it can access only media, video and images. From now on, I added WRITE_EXTERNAL_STORAGE permission to since Android 13 like I made commit to access all full of files.

Feel free to reply or ask question to me. Thank you! :)

Regards

sujitfg1 commented 1 month ago

Hello Martin

Thanks for the commit. I hope this will fix our/all issues like scripta , shaders and font.

I've some other Thoughts about this File Access for example some people might not feel safe if MPV ask Full File Access, and later Maybe criticise it.

So By SAF(Storage Access Framework) it would be great if You can add Specific file permission eg. KWLP ask for specific file permission named Kustom and it can access everything in that file but nothing from others. It would be great privacy features. I hope you understand what I'm trying to say. But From my side you don't need to add it now.

Thank you Sujit Yadav

sfan5 commented 1 month ago

So as far as I know getting back unrestricted read access on Android 11 or later needs MANAGE_EXTERNAL_STORAGE, which requires manual action by the user in permission settings and also Google's approval for shipping an app with this permission in the Play Store. For this reason I have not bothered with that and the current solution if you need full access is to download the "api29" APK. see also https://github.com/mpv-android/mpv-android/issues/709#issuecomment-1542775752

@MartinEesmaa concerning WRITE_EXTERNAL_STORAGE the documentation says:

Note: If your app targets Build.VERSION_CODES.R [Android 11] or higher, this permission has no effect.

So I don't see how that could possibly help.

MartinEesmaa commented 1 month ago

Hi, @sujitfg1. Thank you for replying!

I've some other Thoughts about this File Access for example some people might not feel safe if MPV ask Full File Access, and later Maybe criticise it.

Well, yeah... :/ if we change from WRITE_EXTERNAL_STORAGE to READ_EXTERNAL_STORAGE, this would be read-only access of all files.

Some people may not like full file access if MPV asked liked that, pre API level 33/older than API 33 of maximum Android 12 version uses only WRITE_EXTERNAL_STORAGE, but since Android 13 for currently MPV default uses to read only media, video and images too.

We can take an example what it accepts media file containers of specifications: https://github.com/mpv-android/mpv-android/blob/001a283a8dae3adb1ef095b1454c54af2162ac10/app/src/main/AndroidManifest.xml#L92-L170

Also raw bitstream containers are missing there like .h264, .h265, .h266 and more, so I can add it if I want to.

So By SAF(Storage Access Framework) it would be great if You can add Specific file permission eg. KWLP ask for specific file permission named Kustom and it can access everything in that file but nothing from others. It would be great privacy features. I hope you understand what I'm trying to say. But From my side you don't need to add it now.

Maybe if I can, but I have to look up and try things, but thanks for little offer.

MartinEesmaa commented 1 month ago

Hi, @sfan5. Thank you for the reply!

So as far as I know getting back unrestricted read access on Android 11 or later needs MANAGE_EXTERNAL_STORAGE, which requires manual action by the user in permission settings

Well yes, it's manual option, but it won't show all files unless the user will go to app info and go to Permissions tab to see files & media turned on manually.

Google's approval for shipping an app with this permission in the Play Store.

Yeah... Google manually approves the app by employee to add permission with app before shipping.

@MartinEesmaa concerning WRITE_EXTERNAL_STORAGE the documentation says:

Note: If your app targets Build.VERSION_CODES.R [Android 11] or higher, this permission has no effect.

Oh... I didn't know that but thanks for the tip. :)

Typhonling commented 1 month ago

It is a good idea to use SAF so that it can access SMB-like storage via, for example, the CIFS Documents Provider.

MartinEesmaa commented 1 month ago

Hi, @Typhonling.

Yes, it is good idea to use SAF like access Google Drive, OneDrive, MEGA, FTP, SFTP and more. Like example using permission by ACTION_OPEN_DOCUMENT for read only, but write is ACTION_CREATE_DOCUMENT.

I looked up about Storage Access Framework how user picks folder or cloud storage anything that. https://developer.android.com/guide/topics/providers/document-provider

DocumentsProvider needs require code add to mpv-android to make it work: https://developer.android.com/reference/android/provider/DocumentsProvider

DocumentsProvider and ACTION_OPEN_DOCUMENT hasn't added codes yet to mpv-android, so we might just someone developer wanted to add SAF to mpv-android or maybe I'll do it as possible if I can, but I'm not good writing codes without Android Java and Kotlin skills, but a little bit and I should have look example codes and test it out.

Feel free to reply or ask question to me. Thank you! :)

sujitfg1 commented 1 month ago

@MartinEesmaa Also SAF can work as same as All File access because what we need is MPV to read other file lole .ttf and .lua and After providing specific File Permission Mainly /storage/emulated/0/mpv and putting all Files and scripts into it make MPV work. Also It won't interfere with Google Play Store data privacy terms and won't need a specific approval.

Its win win situation ig?

MartinEesmaa commented 1 month ago

Hi, @sujitfg1.

I think it should work for .ttf font files and .lua script files into mpv-android... but still needs to get access by SAF or other thing like WRITE_EXTERNAL_STORAGE on my forked repository.

You can use mpv.conf to load scripts or/and font files: https://mpv.io/manual/master/#options-scripts https://mpv.io/manual/master/#options-sub-fonts-dir

By going Settings --> Advanced --> Edit mpv.conf can be found there from start menu of mpv-android. Feel free to reply or ask question to me. Thanks!

Sincerely,

sujitfg1 commented 1 month ago

You can use mpv.conf to load scripts or/and font files: https://mpv.io/manual/master/#options-scripts https://mpv.io/manual/master/#options-sub-fonts-dir

The problem is we need to Put those Files into 0 user data which requires root because that the only Folder MPV can read now.

BTW can i get Your forked apk with All file access? Intrested to test it.

MartinEesmaa commented 1 month ago

Hi, @sujitfg1.

The problem is we need to Put those Files into 0 user data which requires root because that the only Folder MPV can read now.

Well, yeah... only the root/superuser can access it, without root it wouldn't access it. :/

BTW can i get Your forked apk with All file access? Intrested to test it.

For sure, yes.

Here: https://github.com/MartinEesmaa/VVCEasy/blob/master/MPV.md#download-mpv-windowslinuxandroid-player-libvvdec--xhe-aac-plugin

You can pick Android API 29 Debug apk, it is recommended.

Optional if you want to debug and see the console messages, Android device with USB debugging toggled on via developer options and must be connected your Android device to PC with ADB installed by adb logcat -s "mpv" on your terminal window on PC.

Let me know by any questions or reply to me. Thanks! :)

sujitfg1 commented 1 month ago

Hello @MartinEesmaa

I'm using your forked apk and have allowed access All files manually.

But I'm still not sure why Custom font and script not working?

# Subtitles
subs-fallback=default
//embedded fonts = <yes|no>
sub-font-size=38.5
sub-font='ACaslonPro-Italic.otf'

#Script
scripts=/storage/emulated/0/mpv/scripts/set_subtitle_font_dir.lua

Script

#!/bin/bash

# Set the subtitle font directory
mpv --sub-fonts-dir=/storage/emulated/0/Download/adobe-caslon-pro

There's any way to check why it is not working also I don't have access to my pc system currently and I'm new comer to MPV so don't know much. Hope I'm not being nuisance to you.

Thank you.