Android Question SoundPool Play folder

stari

Active Member
Licensed User
Longtime User
Hi,
My question: if I upload an effect to "Internal Storage", can I play such an effect with SoundPool?
I tried a few methods, but...no luck!
Thks for your answers!!!
 

stari

Active Member
Licensed User
Longtime User
Assuming that you are asking about XUI.DefaultFolder = File.DirInternal, then yes, you can play from this folder.
Thks Erel
Yes, i wish to play from File.Dir Internal.

B4X:
If File.Exists(File.DirInternal,"Pling.mp3") Then
        Log("OK, file is here")
    Else
        Log("No such file")     
       End If
    End If

When I try the code above, I always get the same answer: No Such file.
However, the file is there.
 
Upvote 0

stari

Active Member
Licensed User
Longtime User
The file isn't there.

Where is the code that copies it to File.DirInternal?
Hi
I copied it manually, tablet connected to PC.
If i try this way:

B4X:
Private Sub ListView1_ItemClick (Position As Int, Value As Object)   
    Dim f As ExternalFile = Value   
    If f = UpItem Then
        'remove the current folder
        FoldersStack.RemoveAt(FoldersStack.Size - 1)
        'get the parent folder which is now the topmost folder
        Dim folder As ExternalFile = GetCurrentFolder       
        'remove it and enter it again
        FoldersStack.RemoveAt(FoldersStack.Size - 1)
        EnterFolder(folder)
        
    Else
        If f.IsFolder Then           
            EnterFolder(f)
        Else If IsImageFile(f.Name) Then
            LogColor("File name:  " & f.Name, Colors.Red)
            Dim in As InputStream = Storage.OpenInputStream(f)           
            'We can open the image directly with Bitmap.Initialize2 however it will not allow us to use LoadBitmapResize
            'so instead we copy it to a temporary file.
            Dim out As OutputStream = File.OpenOutput(File.DirInternal, "temp", False)           
            File.Copy2(in, out)           
            out.Close
            LoadId1= sp1.Load(File.DirInternal,"temp")                                   
            'ImageView1.SetBackgroundImage(LoadBitmapResize(File.DirInternal, "temp", ImageView1.Width, ImageView1.Height, True))
        End If
    End If
End Sub

then i can see the file, load SoundPool and play, but only if it is copied to a temporary file.
I don't really know how to do this programmatically.
 
Upvote 0

stari

Active Member
Licensed User
Longtime User
You can't. The internal storage is not accessble.


You must copy it to a temporary file.
Thks,hm,......
As i say: if i try with your sample ExternalStorage, then i can acces the file.
And, i can load file to InternalStorage. I can see this file, and folder Sounds, on my tablet with MyFiles and Total Commander.
And, also, when i connect tablet with PC, i can save files to this folder.
Also can i load and play, if the file is copied to temp. With your sample.
But, sory, i can't resolve, how to access this folder and file from my App.
I added 3 screen shots so you can see that I sent 2 files and 1 Folder to File.DirInternal.

And, once, with your App I can reach these files and folders.
 

Attachments

  • scrs0.PNG
    63.2 KB · Views: 146
  • scrs1.PNG
    91.4 KB · Views: 131
  • scrs2.PNG
    105.6 KB · Views: 138
Upvote 0

stari

Active Member
Licensed User
Longtime User
OK
but,...... have you some suggestions?
Or sample?

I.m lost there, .....hm, ....
 
Upvote 0

stari

Active Member
Licensed User
Longtime User
You haven't really told us what you are trying to do. If you want to let the user choose a file and then play it then search for ContentChooser
Hi,
I make app, for myself, not for Play Store. Small App with keyboard, piano like.
I can produce different effects, tones, and I could change them by uploading new sounds. I can upload them, but I don't know how to "put" them in a folder, programmatically not manually, where I can play them.
 
Upvote 0

zed

Active Member
Licensed User
Try this

B4X:
Private Sub btOpen_Click
    Dim cc As ContentChooser
    cc.Initialize("cc")
    cc.Show("audio/*", "Choose audio file")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    
    If Success Then
        Dim InStr As InputStream = File.OpenInput("ContentDir",FileName)
        Dim OutStr As OutputStream = File.OpenOutput(File.DirInternal,"YOUR_FILENAME",False)
        File.Copy2(InStr,OutStr)
        OutStr.Close
    Else
        MsgboxAsync("open file error","")
    End If
End Sub
 
Upvote 0

stari

Active Member
Licensed User
Longtime User
Thks. Yes, its what i need.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…