4 <title>Native Client MMInit
</title>
5 <script type=
"text/javascript">
8 var upcallButtonElement
;
9 var shutdownButtonElement
;
10 // SRPC's embeds can launch an arbitrary number of Native Client modules.
11 // Each module is loaded from the web and started in sel_ldr by a call
12 // to the loadURL method on a plugin instance. DownloadCallbacks are
13 // used to report success or failure from module loads.
14 var DownloadCallback = function() {
15 // The onload method is invoked after successful download of a module
16 // and its starting in sel_ldr. It is passed a handle to the module
17 // that can then have services invoked on it.
18 this.onload = function(module
) {
19 // We save the returned handle to the module in a global variable.
20 // This global variable is used to invoke rpcs in helloworld.
22 // Allow the user to push the button (it was disabled by default).
23 upcallButtonElement
.disabled
= null;
24 shutdownButtonElement
.disabled
= null;
26 this.onfail = function(string
) {
27 // If the load or startup of the sel_ldr instance fails, this method
28 // is invoked with an error string.
29 window
.alert('Error: ' + string
);
32 // Init records a couple of HTML elements used for running the tests and
33 // requests the download of the Native Client module.
34 var Init = function() {
35 pluginElement
= document
.getElementById('pluginobj');
36 upcallButtonElement
= document
.getElementById('upcallbuttonobj');
37 shutdownButtonElement
= document
.getElementById('shutdownbuttonobj');
38 pluginElement
.loadURL('mm_init', new DownloadCallback
);
40 // do_upcall is invoked when its button is pressed.
41 function do_upcall() {
43 alert(naclModule
.do_upcall());
48 // shutdown is invoked when its button is pressed.
51 alert(naclModule
.shutdown());
58 <body onload=
"Init()">
60 <h1>Native Client Multimedia Example
</h1>
63 <button onclick='do_upcall()' id='upcallbuttonobj' disabled='true'
>
66 <button onclick='shutdown()' id='shutdownbuttonobj' disabled='true'
>
70 type=
"application/x-nacl-srpc" width=
100 height=
100 />
73 <p>All results from this test are given in the command shell that invoked