BBjSysGui::playSoundUrl
Description
In BBj 22.0 and higher, this method plays the sound from a URL.
Syntax
Return Value | Method |
---|---|
void | playSoundUrl(string url) |
void | playSoundUrl(string url, boolean loop) |
void | playSoundUrl(string url, boolean loop, string mime) |
Parameters
Variable | Description |
---|---|
url | The URL of the audio to play, or "" to stop playing previously specified audio. |
loop | If this boolean value is true, the audio will play in a loop until stopped. |
mime | The BUI client requires an audio MIME type, which can usually be determined automatically from the sound URL. If it's unable to automatically determine the MIME type (e.g. "audio/wav"), you can explicitly specify it here. |
Return Value
None.
Remarks
Each client defines its own set of supported audio formats. Browsers support a broad range of formats, but the Java GUI client is usually limited to AU, AIFF, and WAV.
Mobile browsers only allow sounds to play as a direct result of user action, so this is treated as a no-op in iOS and Android when running in BUI.
Example
Copy
BBjSysGui::playSoundUrl Example
rem ' BBjSysGui::playSoundUrl
filename$ = "sample.wav"
url$ = "https://public.basis.cloud/docsamples/file_example_WAV_1MG.wav"
mime$ = ""
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(25,25,500,200,"playSoundUrl",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.addStaticText(101,5,25,90,25,"Filename:",$8000$)
filename! = window!.addEditBox(102,100,25,390,25,filename$,$$)
window!.addStaticText(103,5,60,90,25,"URL:",$8000$)
url! = window!.addEditBox(104,100,60,390,25,url$,$$)
window!.addStaticText(105,5,95,90,25,"Mime:",$8000$)
mime! = window!.addEditBox(106,100,95,390,25,mime$,$$)
loop! = window!.addCheckBox(107,100,130,250,25,"Loop",$$)
playFile! = window!.addButton(1,15,165,115,25,"Play File",$$)
playFile!.setCallback(playFile!.ON_BUTTON_PUSH,"playFile")
playData! = window!.addButton(2,135,165,115,25,"Play Data",$$)
playData!.setCallback(playData!.ON_BUTTON_PUSH,"playData")
playUrl! = window!.addButton(3,255,165,115,25,"Play URL",$$)
playUrl!.setCallback(playUrl!.ON_BUTTON_PUSH,"playUrl")
playStop! = window!.addButton(4,375,165,115,25,"Stop Loop",$$)
playStop!.setCallback(playStop!.ON_BUTTON_PUSH,"playStop")
process_events
eoj:
release
playFile:
sysgui!.playSoundFile(filename!.getText(),loop!.isSelected(),mime!.getText(),err=oops)
return
playData:
temp = unt
open (temp,err=oops)filename!.getText()
fin$ = fin(temp)
bytes = dec(fin$(1,4))
readrecord(temp,siz=bytes)bytes$
close (temp)
sysgui!.playSoundData(bytes$,loop!.isSelected(),mime!.getText(),err=oops)
return
oops:
i = msgbox(errmes(-1),0,filename!.getText())
return
playUrl:
sysgui!.playSoundUrl(url!.getText(),loop!.isSelected(),mime!.getText())
return
playStop:
sysgui!.playSoundData($$)
return
Version History
See Also
See the BBj Object Diagram for an illustration of the relationship between BBj Objects.
HTML5 Audio: Supported audio coding formats