Doc_Sly
December 9, 2022, 10:43am
1
Hi,
I test the Taifun Player Extention.
i want to play a MP3 on storage/emulated/0/music
but when i clic on my button i have this message
"Runtime error
attempt to invoke virtual method "void android.media.mediaplayer.setaudiostreamtype(int) on a null object reference"
Why do you stop and start with same click..? May be you need to give some interval of time between this two events
Doc_Sly
December 9, 2022, 12:29pm
3
Sorry,
i changed it but i have the same error
BTW, what is your android version?
If it is 10+ then you must move the file into ASD
sorry, ASD it's for SDcard ?
already multiple discussions are there regaring how to access storage in android 10+ by @Taifun @Anke etc etc pls gothrough the forum,
eg
A little trick/tip....
Drag out a canvas to your project, set it to 1x1 pixels in size, but keep it visible.
Drag out a File component
Use these blocks...
[blocksgetASD]
Works in Companion and for compiled apps, tested on Android 10
(should work across all android versions....returning the root of the sdcard in pre 10)
The ASD did not exist before Android 10.
Anke
December 9, 2022, 1:37pm
8
Post the full path (Player.Souce).
Doc_Sly
December 9, 2022, 2:32pm
11
hi,
i removed one "/"
My full path is : file:///storage/emulated/0/Music/Star Wars/Punk Covers - Star Wars.mp3
but, i have same error
Anke
December 9, 2022, 2:38pm
12
Are you absolutely sure this path exists?
If so, does the audio file play, when you try to play it on your device?
Taifun
December 9, 2022, 2:42pm
13
Replace the spaces by %20
See also the Jukebox example here App Inventor Extensions: File | Pura Vida Apps
Taifun
Doc_Sly
December 9, 2022, 2:49pm
14
file:///storage/emulated/0/Music/Star%20Wars/Punk%20Covers%20-%20Star%20Wars.mp3
Doc_Sly
December 9, 2022, 2:54pm
15
i tried with no space in path : file:///storage/emulated/0/Music/StarWars/PunkCovers-StarWars.mp3
i have the firts message "Runtime Error"
use File component to test if the MP3 file exists.
And ask read External Storage permission.
1 Like
Taifun
December 9, 2022, 3:11pm
17
As test rename the file to something simple...
starwars.mp3
Taifun
Anke
December 9, 2022, 3:59pm
18
This path works on all Android versions if the file exists.
Take a screenshot from your device that shows this path.
Note : If you test with the APK, you must request READ permission.
1 Like
Doc_Sly
December 9, 2022, 3:59pm
19
i had the ReadExternalStorage
and my code is working
sorry, my bad, rookie mistake
thanks at all
-- issue solved --
Taifun
December 9, 2022, 5:17pm
20
Doc_Sly:
my code is working
what about the spaces in the filename?
Taifun