Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Mexico City
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Video player using JS and ActiveX

    Hi there!

    I am trying to get the following script to work for a certain .avi file (or the like) under a controlled fashion.
    As far as I know it should work but... it displays no video.

    Can any one, please, tell me what's wrong?
    ***********************************************

    <script language="JavaScript">
    <!--
    function play() {
    avibutton.mouseoverfrstart=0;
    avibutton.mouseoverfrend=16;
    }

    function stop() {
    avibutton.mouseoverfrstart=0;
    avibutton.mouseoverfrend=0;
    }

    //-->
    </script>

    </head>

    <body>
    <h1>Watch the video.</h1><p />

    <object id="avibutton" width="160" height="120">
    <param name="url" value="file.avi">
    <param name="defaultfrstart" value="0">
    <param name="defaultfrend" value="0">
    <param name="mouseoverfrstart" value="0">
    <param name="mouseoverfrend" value="15">
    <param name="focusfrstart" value="0">
    <param name="focusfrend" value="15">
    <param name="downfrstart" value="0">
    <param name="downfrend" value="15">
    </object>

    <form name="form">
    <input name="Play" type="button" value="Play" onclick="play()">
    <input name="Stop" type="button" value="Stop" onclick="stop()">
    </form>

    </body>

    ************************************************

    Thanks in advance.
    Cybersky

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The short answer is: you need to supply a classid for the object.

    Beyond that, the availability of automation depends on:

    1. If the class is registered on your system.
    2. If the class supports automation & can be late-bound.

    I've created an HTA to test whether a given classid is an object available for automation.
    If you'd like try it out, just copy the following code, and save it as "classTest.hta" (or whatever *.hta):

    Code:
    <html>
    <head>
    <title>Class Test</title>
    <HTA:APPLICATION SINGLEINSTANCE = "yes" />
    
    <script type="text/JScript">
    
    function oTest(F){
    
    F.ProgId.value = "";
    F.viProgId.value = "";
    
    var val, P, isValid, wsS;
    
    val = F.clsid.value;
    
    P = /[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}/i;
    
    isValid = P.test(val);
    
    if(+isValid < 1 || val.length > 36){
    alert("The value submitted is not a valid classid.");} 
    
    else{
    wsS = new ActiveXObject("WScript.Shell");
    try{
    wsS.RegRead("HKCR\\CLSID\\{" + val +"}\\"); 
    isAutomation(F, wsS, val);
    }
    catch(e){
    alert("This class is not registered on your system.");
    }
    
    }}
    
    function isAutomation(F, wsS, val){
    var pId, isObj;
    
    try{
    pId = wsS.RegRead("HKCR\\CLSID\\{" + val + "}\\ProgID\\");
    
    isObj = typeof(new ActiveXObject(pId)) == "object";
    
    +isObj < 1 ? alert("Automation error!" + "\n" + "cannot late-bind: "+ pId) : 
    isVIProgId(F, wsS, val, pId);
    }
    catch(e){
    alert("Error: no ProgID found." + "\n" +
     "Automation is not available for this class.");}
    }
    
    function isVIProgId(F, wsS, val, pId){
    var vpId;
    try{
    vpId = wsS.RegRead("HKCR\\CLSID\\{" + val + "}\\VersionIndependentProgID\\");
    F.viProgId.value = vpId;
    }
    catch(e){
    F.viProgId.value = "not available";
    }
    finally{
    alert("Success!" + "\n" + "Automation is available for this class.");
    F.ProgId.value = pId;}
    }
    </script>
    
    <style type="text/css">
    body{
    background:threedface;
    }
    h4{text-align:center;}
    form{
    text-align:center;white-space:nowrap;
    }
    fieldset{
    margin:20px;padding:10px;
    }
    label{
    color:activecaption;
    }
    button{color:activecaption;vertical-align:middle;
    }
    input{
    vertical-align:middle;text-align:center;
    margin:5px;
    }
    .out{
    background:threedface
    }
    </style>
    </head>
    
    <body onload="document.cTest.clsid.select();">
    
    <h4>This HTA will read the system Registry 
    (<small>HKEY_CLASSES_ROOT</small>):</h4>
    
    <form name="cTest">
    <fieldset>
    <legend>Input</legend>
    <label>classid:</label><input name="clsid" size="44" 
    value="0002DF01-0000-0000-C000-000000000046" maxlength="36">
    <button onclick="oTest(this.form)">Automation Test</button>
    </fieldset>
    <fieldset>
    <legend>Output</legend>
    <label>ProgId:</label><br><input name="ProgId" size="75" readonly class="out">
    <br><br>
    <label>VersionIndependentProgId:</label><br><input name="viProgId" size="75" 
    readonly class="out">
    </fieldset>
    </form>
    
    </body>
    </html>
    edit >> Fixed code to clear output on submit.

    edit2 >> Forgot to make pattern case insensitive.
    Last edited by swmr; 02-04-2004 at 10:46 PM.
    hmm... ?

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    This has nothing to do with DOM Scripting.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •