[Gambas-user] Supped up the WebAudio.class

Bruce Steers bsteers4 at gmail.com
Thu Jul 28 13:51:43 CEST 2022


On Thu, 28 Jul 2022 at 10:41, Benoit Minisini <
benoit.minisini at gambas-basic.org> wrote:

> Le 28/07/2022 à 11:33, Bruce Steers a écrit :
> >
> >
> > On Thu, 28 Jul 2022 at 09:41, Benoit Minisini
> > <benoit.minisini at gambas-basic.org
> > <mailto:benoit.minisini at gambas-basic.org>> wrote:
> >
> >     Le 28/07/2022 à 10:28, Benoit Minisini a écrit :
> >      > Le 28/07/2022 à 01:23, Bruce Steers a écrit :
> >      >>
> >      >>   How about a hidden event and use it for passing the data and
> >     firing
> >      >> required event?
> >      >>
> >      >
> >      > Nope.
> >      >
> >      > You must send the 'Position' property from the browser to the
> >     server by
> >      > using:
> >      >
> >      >      gw.update(<id>, '<property>', <value>);
> >      >
> >      > Where <id> is the id of the control, <property> the name of the
> >      > property, and <value> its value.
> >      >
> >      > Then you handle that message on the server in the
> '_UpdateProperty'
> >      > hidden method of the control.
> >      >
> >      > Look at the source code of 'WebTextBox' to see how the 'Text'
> >     property
> >      > is updated when the text changes on the browser.
> >      >
> >      > Once you have updated the property, you can raise the 'Position'
> >     event.
> >      >
> >      > Regards,
> >      >
> >
> >     Note that you have a WebControl '_GetUpdateJS()' method that
> generates
> >     for you the HTML code that calls 'gw.update' when a specific DOM
> event
> >     is triggered.
> >
> >     See again WebTextBox '_Render()' method for an example.
> >
> >
> > Thanks Ben, I've implemented the gw.update() + _UpdateProperty() method
> > and it's sooo much better,
> > the page objects were flickering during play before but now it's looking
> > nice and clean, i guess for the above mentioned refreshing reasons
> >
> > Also now i can get rid of the Observer as no longer needed.
> >
> > Many thanks for the pointers :)
> > Am currently rebuilding and checking out gb.media MediaPlayer for
> > guidance :)
> >
> > Respects
> > BruceS
> >
>
> When a property of a control changes, you usually must refresh it by
> calling the _Refresh() method.
>
> You can avoid a full refresh of the control to speed up things by using
> custom javascript code instead. Look at the SetText() method of the
> WebTextBox control to see an example.
>
> Another point: you must not catch an event on the browser side if you
> don't implement the event handler on the server side.
>
> To detect that, use the 'Object.CanRaise()' method. As usual, look at
> the '_Render' method of WebTextBox for an example.
>

I see so i have my _Render sub like this now...

Public Sub _Render()

  Print "<audio"; Me._GetClassId(); " src=\""; Html(Me._GetLink($sAudio));
"\"";

  Print Me._GetUpdateJS("oncanplay", "duration", "$_(" & JS(Me.Name) &
").duration");
  Print Me._GetUpdateJS("onpause", "pause");
  Print Me._GetUpdateJS("ontimeupdate", "position", "$_(" & JS(Me.Name) &
").currentTime");

  If Object.CanRaise(Me, "End") Then Print Me._GetUpdateJS("onended",
"ended");

  If $bLoop Then Print " loop=\"1\"";
  If $bAutoPlay Then Print " autoplay";
  Print ">"
  If $sSources Then PrintSources
  Print ("Html audio not supported")

  Print "</audio>";

End
Have I understood correctly?

The "End" event is the only event not handled internally, all the others
set a property in the class
>From studying the WebTextBox code i see the _GetUpdateJS() being used so i
did that way.

I only use "If Object.CanRaise()" on the End event as it's the only one
that may not be used.

thanks again :)
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220728/9a3d6e27/attachment.htm>


More information about the User mailing list