Skip to first unread message

Dario Annicchiarico

unread,
Apr 14, 2019, 11:30:07 AM4/14/19
to MIT App Inventor Forum
I made an app using appinventor2 that open a local html page in a webviewer component through the path 'file:///android_asset/..'.
The page contains an html5 audio element whose scr attribute it is dynamically set to "/storage/emulated/0/[file_name].3gp".
I tested this app on my android smartphone version 6 and it worked very well, playing the sound file just created before..
A couple of days ago I decided to update Android version to 8 and I tested again the same app but this time html5 audio player not worked.
In order to verify the cause of the trouble I tested the same application on an older smartphone with Android 5 version installed and the app worked.
I don't Know why but it seems  that probably some permissions to read local audio file from storage directory has been denied to webviewer content.
Could someone help me to solve the issue?

Best regards 

Dario

BodyMindPower

unread,
Apr 14, 2019, 2:57:43 PM4/14/19
to MIT App Inventor Forum
Starting with API 23 (Android 6), the READ/WRITE permissions are requested at runtime. Try this (fi at: Screen.Initialize):

or READ_ EXT...

Anke

Dario Annicchiarico

unread,
Apr 14, 2019, 4:51:13 PM4/14/19
to MIT App Inventor Forum
Thank you, but I tried with no luck.
The file is  written by the same app in the storage folder but when audio element src attribute tries to target the 3gp file something goes wrong.
Therefore if audio src targets a 3gp file located in the assets folder It works and It can play It.
I don't know why.

TimAI2

unread,
Apr 14, 2019, 6:36:33 PM4/14/19
to MIT App Inventor Forum
Try with "file:///mnt/sdcard/[file_name].3gp"

BodyMindPower

unread,
Apr 15, 2019, 3:39:13 AM4/15/19
to MIT App Inventor Forum
file:///android_asset is the path to the assets for the production version of the app (APK). (the development path: file:///mnt/sdcard/AppInventor/assets/)
"/storage/emulated/0/" is the path to the root directory of the internal storage (name that the device is displaying.) This is actually (the root folder of) the external (non-app-specific) storage for which READ / WRITE_EXTERNAL_STORAGE permissions are required).
See here for an excellent overview: https://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE
So we need the AIA or the relevant blocks of your app to help you.

Anke

BodyMindPower

unread,
Apr 15, 2019, 5:48:31 AM4/15/19
to MIT App Inventor Forum

Dario Annicchiarico

unread,
Apr 15, 2019, 11:15:20 AM4/15/19
to MIT App Inventor Forum
I hope to be clear in my exposition.

I have an app showing an html page in a webview.
Throught my html page I can trigger the android sound recorder to record sound from microphone.
When "aftersoundrecorded" event is triggered (see the block below) the app invokes a javascript function inside my html page passing to it a parameter (the path of the sound just recorded)

getSound.PNG











The function creates an audio element setting its src attribute to the path of the sound (file:///) as shown below


javascript.PNG















The output is represented by the following screenshot


audio.PNG










As you can see the audio element is disabled since it is not able to recognize the path that is right and exits at all.

That happens on an Android 8 smartphone but if I install the same application in an Android 6 or 5 it works very well

BodyMindPower

unread,
Apr 15, 2019, 12:09:19 PM4/15/19
to MIT App Inventor Forum
we need to see the block (for the path) of SoundRecoder1.SaveRecording ...

BodyMindPower

unread,
Apr 16, 2019, 4:35:57 AM4/16/19
to MIT App Inventor Forum
As long as we do not know the AIA or the relevant part of it, it will be difficult to help. Maybe it helps to use logcat (see Taifun's advice):

Anke
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Dario Annicchiarico

unread,
Apr 17, 2019, 3:34:16 AM4/17/19
to MIT App Inventor Forum
I can't uploadthe aia file. When I try to publish the post the page gives me an error.
It seems that it doesn't accept that kind of file


BodyMindPower

unread,
Apr 17, 2019, 4:05:40 AM4/17/19
to MIT App Inventor Forum
I sometimes had the same problem and then posted the AIA link from Google Drive or anywhere else ...
Message has been deleted

Taifun

unread,
Apr 17, 2019, 3:28:51 PM4/17/19
to mitappinv...@googlegroups.com
I can't uploadthe aia file. When I try to publish the post the page gives me an error.
the forum does not permit adding aia files, which have extensions inside
alternatively just upload the file to your Google Drive and post the link to the file here

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Reply all
Reply to author
Forward
0 new messages