BBjAppletProxy::playAudio

Description

In BBj 2.02 and higher, this method displays a specified URL in a separate browser frame.

Syntax

Return Value

Method

void

playAudio(string URLName)

void

playAudio(string URLName, string relativeName)

Parameters

Variable

Description

URLName

Specifies an absolute URL giving the base location of the audio clip.

relativeName

Specifies the location of the audio clip, relative to the URL argument.

Return Value

None.

Remarks

In order to display a given URL, the Applet must have security permissions to connect to the host that is providing that URL. The default SecurityPolicy in effect in a browser will only allow an Applet to connect to the host from which the Applet was downloaded. In order to be able to display arbitrary URLs using addFrame(), the SecurityPolicy must be edited to add the permission:

java.net.SocketPermission "*", "resolve"

Example

rem 'Demo program for controlling BBjApplet through AppletProxy

rem 'Obtain the instance of the BBjAPI object
let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Set addWindow param values
X = 0
Y = 0
WIDTH = 960
HEIGHT = 100
TITLE$="BBj Window"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$)

rem 'Add buttons to the window
changeSize! = myWindow!.addButton(101,20,20,100,20,"be Large",$0800$)
innerFrame! = myWindow!.addButton(102,140,20,140,20,"show Internal Frame",$0800$)
outerFrame! = myWindow!.addButton(103,300,20,140,20,"show External Frame",$0800$)
text! = myWindow!.addStaticText(104,460,10,189,10,"select item to display on status bar")
listBox! = myWindow!.addListBox(105,460,25,160,50,"",$0000$)
listBox!.addItem("Program Name")
listBox!.addItem("Config file")
listBox!.addItem("AppServerPort")

rem 'set their colors and text
green! = mySysGui!.makeColor(mySysGui!.GREEN)
blue! = mySysGui!.makeColor(mySysGui!.LTGRAY)
magenta! = mySysGui!.makeColor(mySysGui!.MAGENTA)
changeSize!.setBackColor(green!)
innerFrame!.setBackColor(blue!)
outerFrame!.setBackColor(magenta!)

rem 'get AppletProxy and use it to set bounds of Applet
applet! = BBjApi().getAppletProxy()
applet!.setBounds(200,200,140,100)

rem 'define some boolean values
isLarge = 0
showingInnerFrame = 0
showingGoogle = 0

rem 'Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,CHANGE_SIZE,mySysGui!.getContext(),changeSize!.getID())
CALLBACK(ON_BUTTON_PUSH,DO_INNER_FRAME,mySysGui!.getContext(),innerFrame!.getID())
CALLBACK(ON_BUTTON_PUSH,DO_OUTER_FRAME,mySysGui!.getContext(),outerFrame!.getID())
CALLBACK(ON_LIST_CLICK,DO_LIST_BOX,mySysGui!.getContext(),listBox!.getID())
CALLBACK(ON_LIST_DOUBLE_CLICK,DO_LIST_BOX,mySysGui!.getContext(),listBox!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

rem 'Process Events
process_events

CHANGE_SIZE:
    rem 'escape
    if (isLarge)
        x! = javax.swing.UIManager.getLookAndFeel()
        print x!.toString()
        java.lang.System.out.println(x!.toString())
        changeSize!.setText("Enlarge Applet")
        isLarge = 0
        applet!.showStatus("Shrinking Applet....")
        program$ = applet!.getParam("BBjProgram")
        applet!.setBounds(200,200,140,100)
    else
        isLarge = 1
        changeSize!.setText("Shrink Applet")
        applet!.showStatus("Enlarging Applet")
        if showingInnerFrame
            applet!.setBounds(0,0,960,620)
        else
            applet!.setBounds(0,0,960,100)
        endif
    endif
return

DO_INNER_FRAME:
    if (showingInnerFrame)
        applet!.setBounds(0,0,960,100)
        innerFrame!.setText("show internal frame")
        applet!.showStatus("inner frame removed....")
        applet!.removeFrame("frame1")
        showingInnerFrame = 0
    else
        applet!.setBounds(0,0,960,620)
        applet!.addFrame(0,100,960,520,"https://www.google.com","frame1")
        innerFrame!.setText("remove internal frame")
        applet!.showStatus("internal frame added")
        showingInnerFrame = 1
    endif
return

DO_OUTER_FRAME:
    if (showingGoogle)
        applet!.showDocument("https://www.poweredByBBj.com", "frame_1")
        applet!.showStatus("showing www.poweredByBBj.com in external frame")
        outerFrame!.setText("Show google.com")
        showingGoogle = 0
    else
        applet!.showDocument("https://www.google.com", "frame_1")
        applet!.showStatus("showing www.google.com in external frame")
        outerFrame!.setText("Show poweredByBBj.com")
        showingGoogle = 1
    endif
return

DO_LIST_BOX:
    applet!.playAudio("file://c:\winnt\media\tada.wav")
    switch listBox!.getSelectedIndex()
        case 0
            message$ = "BBjProgram: " + applet!.getParam("BBjProgram")
            break
        case 1
            message$ = "BBjConfig: " + applet!.getParam("BBjConfig")
            break
        case 2
            message$ = "AppServerPort: " + applet!.getParam("AppServerPort")
            break
    swend
    applet!.showStatus(message$)
return

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

See Also

BBjAPI

Object Variables

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.