Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File selection problem
#1
Using Delphi 11.2 and Intraweb 15.2.66 and the iwaudio component. Starting from the audio demo in the version 14 demo files, I can get a browser screen that correctly plays a file that I enter during development. That is, in the component editor I enter "alert.ogg" in the AudioFile>Filename field, that file is in the wwwroot directory, and pressing the play button on the component or clicking a button with the action of "IWaudio1.play;" - the file plays and all is well.
What I want to do is have a couple other buttons that change the file name (e.g. "IWaudio1.AudioFile.Filename := 'laugh.ogg';") and now when the play button is clicked, that file will play.
It appears that the file name doesn't change and it always plays the design time file. How do get the file to change so I can play a selected file? Thank you.
...
Reply
#2
What you’re running into is how IWAudio works at runtime. The filename you set at design time gets sent to the browser when the page is rendered. Changing the Filename property later on only affects the server object, the server does not automatically update the client side audio element. So the browser keeps playing the original file you set at design time.

The fix is to force the control to update on the client. After changing the filename, call IWAudio1.AsyncRefresh, or trigger a full region or form refresh. Another common approach is to set the filename in an async button event and then call Play immediately after the refresh. In practice, most developers place IWAudio inside an IWRegion and call Region. Refresh after setting the new filename. That pushes the updated Rabbit Road game source to the browser, and the next Play will use the new file.

The key point is that the browser must receive the new source before playback starts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)