srsm
08-04-2008, 03:26 PM
Hi,
My second major attempt to get video working without a control panel. I need to play, stop, step etc programmatically. Using IE7 and FF2 but obviously need all browsers to work (except perhaps really old versions).
I've tried countless methods but all fall short when it comes to allowing me to control the video with my own javascript. Initial main problem (at least in IE7) is the Player.URL = videoname; automatically starts the video even with autostart param set to false (also tried 0). Thereafter, the availability of the controls appears to depend on some timing issue. E.g. if I test for isAvailable ('currentPosition') the code says no but actually setting currentPosition works.
I've also had endless problems with changing settings that help the code to work in IE but then break FF e.g.
moviesID.windowlessVideo = true; // doing this in JS instead of object appears to help IE but break FF
//Or for balance
moviesID.uiMode = "none"; // this worked as FF param but not IE param
Sadly, my last attempt was in June (more or less all of June) and it is a while ago so cannot recall all details but the document.write approach seemed to be much easier to work with. I've missed out the test for IE/FF and FF object setup but you can see that in the msdn link provided. I want to avoid the embed approach as it is deprecated.
I tested this in w3schools TryIt (kind of handy for a quick cut and paste) and video link came from there. (Reason I mention this is because the video is WMV v8 and I've also tried WMV v7 and v9 files). My WMP is at v11.
<html>
<body>
<h2>Playing The Object</h2>
<script type="text/javascript">
// based on technique in
// http://msdn.microsoft.com/en-us/library/bb614509(VS.85).aspx
// this approach (document.write) did seem to help but not sure why
document.write('<object id="Player"');
document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
document.write(' type="application/x-oleobject"');
document.write(' <param name="autostart" value="false" />');
document.write(' width=320 height=240></object>');
moviesID = document.getElementById("Player");
moviesID.windowlessVideo = true;
moviesID.stretchToFit = true; // make it fit window
moviesID.uiMode = "none"; // this worked as FF param but not IE param
//movies.autoStart = 0;
var theImage="http://www.ananova.com/about/vap_windows_check.wmv";
//movies.autoStart = false;
moviesID.URL = theImage;
//moviesID.controls.stop(); // when comments removed different controls
// become available. E.g. with no stop quickly clicking alerts the 'play'
// alert is not shown. But, if the video is allowed to complete before click
// okay then the 'play' alert is reached...
//If the movies is stopped above then the 'stop detected' is never reached
if (moviesID.controls.isAvailable("stop") )
alert ("stop detected"); // stop never detected
if (moviesID.controls.isAvailable("play") )
alert ("play detected"); // play never detected
if (moviesID.controls.isAvailable("currentPosition") )
alert ("current position detected"); // currentPosition never detected
moviesID.controls.currentPosition = 2; // but it works - change this 0-3
moviesID.controls.play(); // Movie starts due to URL being set???
</script>
</body>
</html>
To re-iterate I've tried dozens of combinations of object/embed/clsid and countless combinations of parameters. Nothing seems to work reliably (sometimes running a 'dummy' video helped expose the controls properly for the real run but not ideal).
In summary, I have autostart set to false. I set the URL for the video and expect to be able to control the video via play but it charges off instantly and only some of the controls are available (and when they are sometimes isAvailable says they are not).
Regards
srsm
My second major attempt to get video working without a control panel. I need to play, stop, step etc programmatically. Using IE7 and FF2 but obviously need all browsers to work (except perhaps really old versions).
I've tried countless methods but all fall short when it comes to allowing me to control the video with my own javascript. Initial main problem (at least in IE7) is the Player.URL = videoname; automatically starts the video even with autostart param set to false (also tried 0). Thereafter, the availability of the controls appears to depend on some timing issue. E.g. if I test for isAvailable ('currentPosition') the code says no but actually setting currentPosition works.
I've also had endless problems with changing settings that help the code to work in IE but then break FF e.g.
moviesID.windowlessVideo = true; // doing this in JS instead of object appears to help IE but break FF
//Or for balance
moviesID.uiMode = "none"; // this worked as FF param but not IE param
Sadly, my last attempt was in June (more or less all of June) and it is a while ago so cannot recall all details but the document.write approach seemed to be much easier to work with. I've missed out the test for IE/FF and FF object setup but you can see that in the msdn link provided. I want to avoid the embed approach as it is deprecated.
I tested this in w3schools TryIt (kind of handy for a quick cut and paste) and video link came from there. (Reason I mention this is because the video is WMV v8 and I've also tried WMV v7 and v9 files). My WMP is at v11.
<html>
<body>
<h2>Playing The Object</h2>
<script type="text/javascript">
// based on technique in
// http://msdn.microsoft.com/en-us/library/bb614509(VS.85).aspx
// this approach (document.write) did seem to help but not sure why
document.write('<object id="Player"');
document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
document.write(' type="application/x-oleobject"');
document.write(' <param name="autostart" value="false" />');
document.write(' width=320 height=240></object>');
moviesID = document.getElementById("Player");
moviesID.windowlessVideo = true;
moviesID.stretchToFit = true; // make it fit window
moviesID.uiMode = "none"; // this worked as FF param but not IE param
//movies.autoStart = 0;
var theImage="http://www.ananova.com/about/vap_windows_check.wmv";
//movies.autoStart = false;
moviesID.URL = theImage;
//moviesID.controls.stop(); // when comments removed different controls
// become available. E.g. with no stop quickly clicking alerts the 'play'
// alert is not shown. But, if the video is allowed to complete before click
// okay then the 'play' alert is reached...
//If the movies is stopped above then the 'stop detected' is never reached
if (moviesID.controls.isAvailable("stop") )
alert ("stop detected"); // stop never detected
if (moviesID.controls.isAvailable("play") )
alert ("play detected"); // play never detected
if (moviesID.controls.isAvailable("currentPosition") )
alert ("current position detected"); // currentPosition never detected
moviesID.controls.currentPosition = 2; // but it works - change this 0-3
moviesID.controls.play(); // Movie starts due to URL being set???
</script>
</body>
</html>
To re-iterate I've tried dozens of combinations of object/embed/clsid and countless combinations of parameters. Nothing seems to work reliably (sometimes running a 'dummy' video helped expose the controls properly for the real run but not ideal).
In summary, I have autostart set to false. I set the URL for the video and expect to be able to control the video via play but it charges off instantly and only some of the controls are available (and when they are sometimes isAvailable says they are not).
Regards
srsm