"Prepare failed" error with media player after file copy

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I get a "Prepare failed" error when the code is run on the media load statement. Can you check the code and tell us what to fix to stop the errors?

If I use File.DirRootExternal it works ok and no errors.
If I use File.DirDefaultExternal it works ok and no errors.

Using File.DirAssets gives a "no such file or directory" error.
Using File.DirInternal gives a "prepare failed" error.
Using File.DirInternalCache gives a "prepare failed" error.

Thanks.

B4X:
Sub DownloadedMp3File

   ProgressBarDownloading.Indeterminate = True
   ProgressBarDownloading.Visible = True
   
    HttpUtils.Download("Job1", mp3Url)
End Sub


Sub JobDone(Job As String)

  Select Job
        Case "Job1"

            If HttpUtils.IsSuccess(mp3Url) Then 

            Dim mp3 As InputStream
                mp3 = HttpUtils.GetInputStream(mp3Url)
                File.Copy2(mp3,File.OpenOutput(File.DirInternal,"077.mp3",False))

            ProgressBarDownloading.Visible = False

            ToggleButtonPlayPause.Checked = True
            ToggleButtonPlayPause.Enabled = True
            blnCurrentPauseCheckedState = True
            blnCurrentPauseEnabledState = True
   
            mpTheMediaPlayer.Release
            mpTheMediaPlayer.Initialize2("SurahAlMorsalat")
            mpTheMediaPlayer.Load(File.DirInternal, "077.mp3")
            mpTheMediaPlayer.Play
            End If
    End Select
End Sub
 
Last edited:

rleiman

Well-Known Member
Licensed User
Longtime User
Do you know roughly when the next version will be ready?

We look forward to it.


No. MediaPlayer cannot access the internal folder as it is hosted in a separate process.

I believe that there is a workaround but it will only be possible to apply it in the next version.
 
Upvote 0

NFOBoy

Active Member
Licensed User
Longtime User
Resolved?

Erel, am using 1.92 and get the same error when trying to copy sound files out of database (as a blob) to the internal directory, and then loading them into MediaPlayer. (works perfectly with File.DirRootExternal.... but if I understand correctly, if DirInternal is used... no special permission required... and that would be the only one my app would need)

Is this resolved in 2.0?

If not, is there a way to load soundfiles that are stored as Blob's directly to MediaPlayer without saving them as a file first?

Thanks!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…