Android Question Musical notation

T201016

Active Member
Licensed User
Longtime User
Hello all,
while testing "musical notation" -
An error an ocurred in sub: abcsongs_calljavascript (java line:123).

A Webview method was called on thread 'JavaBridge'. All Webview methods must be called on the same thread.

B4X:
'Javascript injection to call JS functions
Private Sub CallJavaScript(WV As WebView, JSString As String)
    WV.LoadUrl(JSDomain & JSString)
End Sub

'JS Calls
Sub Load(FilePath As String,FileName As String)
    Loaded = False
    Loading = True
    Dim FileData As String = File.ReadString(FilePath,FileName)
    Dim FileArr() As Byte = BC.StringToBytes(FileData,"UTF-8")
    Dim JSString As String = "loadFile(" &SU.EncodeBase64(FileArr) & ")"
    CallJavaScript(WebView1, JSString)
End Sub

In this arrangement, the musical score is not displayed in any way.

do you have any idea for a solution?
 

Attachments

  • Screenshot_2020-05-24 Bug - Error - Display musical notation(1).png
    Screenshot_2020-05-24 Bug - Error - Display musical notation(1).png
    5.1 KB · Views: 227
Last edited:

T201016

Active Member
Licensed User
Longtime User
Welcome back,

Interested in the example of the Stevel05 project - ABC4jInline,

this thought occurred to me -
is there another way to get the value of the Url variable, see: Sub WebView1_OverrideUrl (Url As String)
than pressing "download midi" in hyperlink?

I know the "renderSong" function is responsible for creating the hyperlink:

B4X:
'Convert the song to a byte array so we can encode it

Dim SongArr () As Byte = BC.StringToBytes (Score.ToString, "UTF-8")

Dim JSString As String = "renderSong ('" & SU.EncodeBase64 (SongArr) & "'," & ParserParams & "," & PrinterParams & "," & RenderParams & ")"

CallJavaScript (WebView1, JSString)

Certainly this would require modification in the library sources - (abcjs_basic_1.10-min.js)
However, I would like to replace the hyperlink with a graphic button, for example, some example in B4A.

B4X:
Sub WebView1_OverrideUrl (Url As String) As Boolean


Dim SU As StringUtils

    Dim StrData As String

    Dim buffer () As Byte

    Dim out As OutputStream


    MediaPlayer1.Initialize 'Set up media player

    StrData = Url.Replace ("data: audio / midi,", "") 'Strip off the beginning bit

    StrData = SU.DecodeUrl (StrData, "ISO-8859-1") 'Decode the url

    buffer = StrData.GetBytes ("ISO-8859-1") 'Change to byte array

    'Save the file to temp.mid

    out = File.OpenOutput (File.DirRootExternal & "/ Download", "temp.mp3", False)

    out.WriteBytes (buffer, 0, buffer.Length)

    out.Close

    'Play the file

MediaPlayer1.Load (File.DirRootExternal & "/ Download", "temp.mp3")

    MediaPlayer1.Play

Return True

End Sub
 

Attachments

  • Screenshot_2020-05-29.png
    Screenshot_2020-05-29.png
    25.5 KB · Views: 249
Last edited:
Upvote 0
Top