Update
Using document.write to build the object doesn't work in this context. There needs to be a delay before the object has initiated (guess). Oddly, the impact neatly simulates the problems I have been having (which is why I missed it when building up my mock-up test code).
I've made considerable progress on account of ignoring isAvailable and setting delays after many of the control operations. I now have a cascade of functions which firstly setup the player with uiMode URL etc but in a special way to cope with IE/FF inconsistencies - initMovie() then I Play the video followed by a setTimeout to the next function.
getDuration(). This captures the player.currentMedia.duration and sets the currentPosition and then another short delay before...
videoPositioned(). All this took place off screen using absolute positioning. Now that most of the work is done move on screen and then Play the video again (this to force the video to apply the set currentPosition) then another delay (which sadly needs to be quite long. Currently set to 500 milliseconds. Get this wrong and on FF the video will appear only randomly... yikes. Note the commented out but handy method for passing a parameter with a setTimeout. This calls...
videoReady(). Which simply pauses to enable the operator to decide what to do with the video. For example I use controls.step(1) to move one frame at a time and use setInterval (with some logic to know when to quit) to move slowly forwards/backwards (step(-1)) a frame at a time. Changing the delay changes the video speed (I should be able to do let the user modify this speed too). See code below.
I know this is total madness but it looks as though it will work. I need to do more to hide the video in some way until it has paused (I also set the volume to 0 when not testing). I've also recalled the advice to use FLV but these were equally hellish to use in particular TGoto TStop etc. I don't have any of the really expensive tools so that didn't help.
Setting up the object like this should do it (not FF version - see previous posts).
Code:
<object id="Player" width="320" height="240"
classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
<param name="uimode" value="none" />
<param name="autostart" value="0" />
</object>
Note there are a few global vars e.g. moviesID (the Player), theImage, moviesDOM.
Code:
function initMovie (showMe) {
// start video to expose functions
moviesID = document.getElementById("Player");
if (browser == "IE") {
moviesDOM.style.bottom = "70px"; // simple solution to IE hiding icons
// http://msdn.microsoft.com/en-us/library/bb249373(VS.85).aspx Only set at design time and upsets Vista!!!
moviesID.windowlessVideo = true; // doing this here instead of object appears to help IE but break FF
moviesID.stretchToFit = true; // make it fit window
}
moviesID.uiMode = "none"; // this worked as FF param but not IE param - vital for IE here
//moviesID.settings.volume = 0;
theImage = "full http//pathtovideootherwiseFFgetsupset" + showMe;
//theImage = "mms://wm.microsoft.com/ms/msnse/0410/23725/PhotoStory/Photostory_demonstration_MBR.wmv";
moviesID.URL = theImage;
moviesID.controls.play(); // in FF the first time around the play doesn't work unless the entire path is provided
// wait an interval to allow to start then proceed in next function
setTimeout ("getDuration()", 500); // Need a pause or currentMedia.duration won't be available
}
function getDuration () {
var duration = moviesID.currentMedia.duration;
moviesID.controls.currentPosition = Math.floor(duration / 2); // cP needs to come just before play - just put to middle of video for a test
setTimeout ("videoPositioned ()", 15); // need to allow time for play to start
// FF needs just a 1 millisecond delay (plus function call losses).
// IE needs around 15 milliseconds
}
function videoPositioned () {
// from http://www.makemineatriple.com/2007/10/passing-parameters-to-a-function-called-with-settimout/
//setTimeout(function(){myFunction(parameter); parameter = null},myTimeout);
moviesDOM.style.left = "10px"; // video was tucked away out of sight - need to do this here or FF gets upset
// now play - and delay to allow play to settle
moviesID.controls.play();
setTimeout ("videoReady()", 500); // need to allow time for play to start
// 5:40pm 5th August Video starts and pauses at midpoint in both IE and FF.
// longer pause here helped (was 15 now 500). Perhaps this can be lowered but problem intermittent so hard to test
// IE still hides the elements that should float on top of the video (FF great)
}
function videoReady () {
// now pause - the movie is ready to play with...
moviesID.controls.pause ();
}
Code to move slowly through the video in either direction. Stepper is global to hold state outside potential infinite loop. A really nice sense of control is obtained. Much better than the clumsy sliders on the player itself.
Code:
function oneUp ()
{// First call to oneUp appears not to work. Press Up button again - works fine thereafter
var moviesID = document.getElementById("Player");
if (stepper < 110) {
stepper = stepper + 10;
moviesID.controls.step(1);
uptimer = setTimeout ("oneUp()", 100); // 100 milliseconds - change this to control speed
}
else {
stepper = 0;
clearTimeout(uptimer);
}
}
function oneDown ()
{
var moviesID = document.getElementById("Player");
if (stepper < 110) {
stepper = stepper + 10;
moviesID.controls.step(-1);
downtimer = setTimeout ("oneDown()", 100);
}
else {
stepper = 0;
clearTimeout(downtimer);
}
}
This took weeks of mind numbing effort (and may not be complete). The Flash approach was just as bad. This can't be how the WMP is meant to be controlled - I'm sure I've missed something which will blow all this nastiness away.
Hope someone can make use of it or explain why I need to go to such lengths.
Cheers
srsm
Bookmarks