Page 249 - DCAP303_MULTIMEDIA_SYSTEMS
P. 249

Unit 14: Designing for World Wide Web (WWW)



            The player itself is embedded using this code:                                        notes
            <object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000”
                width=”40”
                height=”40”
                id=”audio1”
                align=”middle”>
                <embed src=”wavplayer.swf?gui=mini&h=20&w=300&sound=success.wav&”
                    bgcolor=”#ffffff”
                    width=”40”
                    height=”40”
                    allowScriptAccess=”always”
                    type=”application/x-shockwave-flash”
            />
            </object>




            A little javascript provides a link to the player:

            <script>
            function getPlayer(pid) {
               var obj = document.getElementById(pid);
               if (obj.doPlay) return obj;
               for(i=0; i<obj.childNodes.length; i++) {
                 var child = obj.childNodes[i];
                 if (child.tagName == “EMBED”) return child;
               }
            }
            function doPlay(fname) {
               var player=getPlayer(“audio1”);
               player.play(fname);
            }
            function doStop() {
               var player=getPlayer(“audio1”);
               player.doStop();
            }
            </script>
            You can then drive the player from a link or a button like this:
            <a href=”javascript:doPlay()”>doPlay()</a>
            doPlay()
            <form>
            <input type=”button” value=”Play Sound” onClick=”doPlay()”>
            </form>


                                             LoveLy professionaL University                                   243
   244   245   246   247   248   249   250   251   252   253   254