Play mp3 using Dom, Java Hashtagchanged

Happy new year to you all :slight_smile:

To play an mp3 track within in android I have created a xojo web app containing a webHTMLviewer.

The webHTMLviewer loads a remote html5 page containing the audio player code being:

[code]

Your browser cannot handle HTML5. [/code]

I want to be able to use the session.hashTagChanged event handler but of course the code within the html page is changing the hashtag of it’s parent browser window and is not visible within my app.

How can I change the hashtag of the xojo app window when the html player has completed using DOM??

Thanks in advance…
James

From JavaScript :

Dim hashTag as string = "whatever" Self.ExecuteJavaScript("window.location.replace('#'"+hashTag+"')")

Given what you are currently using HashTagChanged for (getting a variable back from JavaScript), you may want to read about WebSDK TriggerServerEvent, in WebSDK.Pdf, in the Extras folder, nest to the Xojo IDE executable.

Hi Michel
Not sure as to where you would place this and or how it would be initiated…

[quote=239044:@James Moore]Hi Michel
Not sure as to where you would place this and or how it would be initiated…[/quote]

OK. Time to back up it seems. Your question was :

It seemed to imply you knew where and when you wanted to change the hashtag. Which is exactly what the code I posted does. Now the question becomes : what do you want to achieve exactly with that change in HashTag ?

Hi Michel
The code within the html page containing the player as originally shown in my question will of course trigger the alert box.

It will also change the hashtag of the remote html page when viewed directly via a browser.

However my problem is how I trigger the true window session.hashtag when viewing via the xojo app which contains HtmlViewer1 containing the url of the remote html page with the media player.

I hope that makes sense…

I do not know what you mean by "trigger the true window session.hashtag ".

If what you mean is you want to restore the previous hashtag after using it to get a JavaScript variable back, simply store Session.HashTag in the window Shown event into a property, and put it back in HashTagChanged after you got “session_completed”).

You really want to look into using a WebSDK control instead, so you will not have to go through that.

Hi Michel
Thanks for you patience so far.
I dont need to restore the previous hashtag…

The javascript i have within the html page( located remotely) will change the hashtag of the remote page only.
I want it to change the hashtag within the xojo app window not the remote html.

Because of my lack of understanding of how java script works within xojo web i dont know how pass that variable back to the session.

To put the question another way:

-Is it possible to have htmlveiwer within a xojo web which shows a remote html page, the remote html page has the media player code.
On completion of the track located on the remote page is it possible to pass a variable back to the main xojo app.session (via the htmlveiwer) to inform the app that the track has completed.?

You have previously kindly shown me how to play a track and check for completion using a label, with java script and Dom within xojo but this method does allow sound tracks to be played within android.

I have assumed that using the same approach may be a solution to this scenario.
Or is this not the case?

Hi Michel
After reading your earlier posts I can see why this doesn’t work now.

As you suggested I have looked at the webSDK and created a web controlWrapper
myHTMLarea
with and event handler setupHTML:

Return "<div id=""" + self.ControlID + """>" + html + "</div>"

myHTMLArea1
has an open event handler.

me.html = app.kPlayer

I have created the app.constant :

[code]

[/code]

The player runs ok…
The alert is not shown and the hashtag isn’t changed.

Is there another way of returning the completed status of the track?

I’ll look into this today.

Thank you so much Michel, I really appreciate your help.

OK. I quickly played with HTMLArea, but it does not support the player.

Here is the code you need to trigger the Hashtag in the WebPage from inside the HTMLViewer :

<script> var aud = document.getElementById("myAudio"); aud.addEventListener("ended", function() { alert("The audio has ended"); window.parent.location = window.parent.location + '#Session_completed' }); </script>

Tried it no joy…
No alert or change in hashtag…

player.xojo_binary_project

THANKS MICHEL

Yep that works.

Shame there is no support for the player though…
would have life a bit simpler
James