Error 701 when loading file from external storage

I'm trying to make it so it plays an .mp3 file when you press Button1, but when I press the button it shows an error.

You found an old example, which stores the file somewhere in an arbitrary directory

Android has been restricted and usually we store files in ASD - application specific directory now...
For more se here Some basics on Android storage system

Just delete global variable strPath and it might work then... if not, let us know...

Taifun

Thank you for the help. I deleted strPath but it's still giving me error 701.


Cameron

The Player component needs an absolute or full path.

On this occasion, it should be noted that it is not possible to download a (media) file into one of the Shared folders with the Web component by setting DefaultFileScope = Legacy. Because then you get an error message "Error 908: The permission WRITE_EXTERNAL_STORAGE has ..." on Android 11+.

This permission should either not be requested automatically at all or only on Android versions lower than 11. → @ewpatton

1 Like

I will need to think about that.

The Legacy file scope was never intended on our end to be a free-for-all in terms of functionality. When we had to start supporting scoped storage on the Android side the hope was that people would be able to use the Legacy mode to migrate their data to be compatible with the scoped storage constraints placed by Android. For folks using newer Android versions, the fact that it causes errors isn't surprising because when I designated the mode as Legacy my intent was that we would not support it on newer versions of Android.

Other methods like downloading to private storage and then copying/moving the file with the File component should provide a solution.

Yes, we have had similar problems before, among other things, with Canvas and the peculiarity that DefaultFileScope only works on Screen1. And in the end, in order not to make it too complicated, the result / compromise was that you should use the File component to copy/move the image from the ASD to one of the shared folders.

However, in this case I stick to my opinion, which I have expressed many times before, that it is (should not be) a problem to remove the automatic permission request and leave it to the developer to request WRITE permission on Android < 11 manually.

Are Android versions > 10 (e.g. Android 11) really still new? I do not think so.

New here refers to versions of Android before/after the enforcement around scoped storage. It has nothing to do with temporal newness. As far as I am concerned, Legacy is Legacy as it is just not viable for our team to continue to update its semantics with every new Android release.

Yes, and that's not necessary, it's enough to remove the automatic permission request.

@ewpatton Probably it makes sense to provide another file scope for advanced users, who like to manage the permissions themselves?

Taifun

Thank you, this fixed it for me. I appreciate your help.

Why did you mark post #2 from @Taifun's as a solution?

As I said

If you only enter the file name as Player.Source, the sound will only be played if the source file (MP3) is in the assets.

1 Like

Together with setting Default File Scope to Asset
Taifun

:question:

What should the Player.Source have to do with DefaultFileScope? Nothing.

If you only enter the file name as Player.Source , the sound will only be played if the source file (MP3) is in the assets and Default file scope in the Screen properties is set to Asset

In case the Default file scope is set to App (which is the default), then the Player component will not find the file as you explained yourself, because it needs an absolute or full path

The question here is: why is the Player component not able to find the file? A relative path should work, too... in this case relative to the default file scope, here the ASD... @ewpatton

Taifun

No.

DefaultFileScope can/should affect components that can store something. The Player component only requires read access and this usually requires an absolute or full path, regardless of the DefaultFileScope. The only exception is playing from the assets, for which only the file name is required.


PS: By the way, the situation is no different with your TaifunPlayer extension.

I have now removed the solution marker to avoid further confusion.

This is your own definition... from the documentation

DefaultFileScope

Specifies the default scope used when components access files. Note that the File component has its own property for controlling file scopes.

The idea behind App Inventor is to be as user friendly as possible... a user does not really understand, that a full or absolute path is required in this case...

Taifun

No, nothing is further from me than formulating a definition for something that I did not design myself and that I have criticized often enough. It is simply my experience. Let's take the Image component as an example. It doesn't matter which DefaultFileScope was chosen, the Image component basically requires an absolute path and, on newer devices, a full path. So as already said, DefaultFileScope can / should specify the storage location for components that can save something. So if DefaultFileScope = App was set, ONLY the filename is needed to save to the ASD. If DefaultFileScope = Legacy or Shared is set, a relative path is needed to save to one of the shared folders (at least on Android 11+, on Android versions < 11 it can be saved to any location in the external storage. However, there are exceptions . Hence my wording "can / should". An exception is e.g. the SoundRecorder component, which basically requires an absolute path.

Yes, who actually understands that, but it is just the way it is. And there are numerous inconsistencies that may also have arisen from Google's idiotic annual targetSdkVersions and AppInventor is constantly faced with the problem of keeping existing apps compatible with the new targetSdk requirements.