iOS Question how to play file in media player with webview overide

joop

Active Member
Licensed User
Longtime User
I have some mp3 files in the DirAssets directory and some buttons in a webpage.
When a button is pressed the webview overide sub gives this file location.

debug mode file location
URL_override button = file:///private/var/mobile/Containers/Data/Application/A8915E2D-1D5C-4FB1-911B-8098DFDED499/tmp/virtual_assets/koe11025.mp3

release mode file location
this location will be completely different, it's in Containers/Bundels/etc don't like this.


How can I play this with mediaplayer in debug and release mode.

In B4A this was so easy

B4X:
If Url.EndsWith("mp3") Then
  Url=Url.Replace("file:///android_asset/","") 'strip file:///android_asset
  Player.Load(File.DirAssets,Url)
  Player.Play
  Return True
End If

But with B4I I don't get it right the file location are different in debug and release mode
how can I get this right, or should i just search for the mp3 file name in both strings
(Debug and Release) and play the file with see below.

B4X:
 Player.Initialize(File.DirAssets,filename,"Player")
Player.Play
 
Last edited:

joop

Active Member
Licensed User
Longtime User
What i now do is this :

HTML =

B4X:
<input type="button"  class="knop"  onClick="parent.location='koe11025.mp3'"  >
<input type="text"  value=" Koe" readonly>

When clicked on button URL override function is called and gives:

URL_override button = file:///private/var/mobile/Containers/Data/Application/A8915E2D-1D5C-4FB1-911B-8098DFDED499/tmp/virtual_assets/koe11025.mp3

Then I parse the full url searching fore mp3 :


B4X:
Sub Getfilename(value1 As String ) As String
Dim pos,i As Int
Dim filename,slashchar As String   
  value1=value1.ToLowerCase
  pos =value1.Indexof("mp3")   
  For i = 1 To 30  'filename not longer 30
    pos = pos -1  'last characters must be mp3
    slashchar =value1.CharAt(pos) 
    If slashchar = "/" Then Exit
Next
filename=value1.SubString(pos+1)
Return filename
End Sub

This is wat you meant ?
 
Upvote 0
Top