You could try an innerHTML approach rather than trying to reuse the object/embed with DHTML.
First rewrite the HTML as follows:
<body>
<p><span class="fontStyle">Introduction</span></p>
<div id="video">
<object id="Player" width="100%" height="100%" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="border:0px;">
<param name="autoStart" value="True">
<param name="uiMode" value="full">
<param name="volume" value="50">
<param name="mute" value="false">
<param name="URL" id="objectSrc" value="">
<embed src="" id="vidEmbed" width="100%" height="100%" autostart="true" uimode="full" volume="50" mute="false"> </embed>
</object>
</div>
</body>
Then in javascript,
var videoString = "<object id=\"Player\" width=\"%sW\" height=\"%sH\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" style=\"border:0px;\">" +
"<param name=\"autoStart\" value=\"True\">" +
"<param name=\"uiMode\" value=\"full\">" +
"<param name=\"volume\" value=\"50\">" +
"<param name=\"mute\" value=\"false\">" +
"<param name=\"URL\" value=\"%sURL\">" +
"<embed src=\"%sURL\" width=\"%sW\" height=\"%sH\" autostart=\"true\" uimode=\"full\" volume=\"50\" mute=\"false\"></embed>" +
"</object>";
(Not tested)
Then use global regular expression videoString.replace(.....) to replace %sW, %sH, %sURL with appropriate values and document.getElementById("video").innerHTML = .... to poke this HTML into the DOM.
Agreed, it shouldn't be necessary but it might just work.
You can do this within a if(){} condition such that it only applies to IE thus leaving your good FF etc. code intact, and also allowing videoString to be simplified (no need for "").Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
edDev,
Try Bob's method first. It looks good to me.
I thought there was a way to address both Object and Embed but it is several years since I had to do it. I'm sure I must have forgotten more than I remember these days.
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
From his photo, I think that Bob is big enough to look after himself, but since I am around and Bob isn't, I hope he will forgive me for answering on his behalf.
Bob's script is written as a function, setplay , such that thisfile , ww and hh are specified when it is called, eg. setplay('myvid1.wmv', '320', '240'); .
I think you will find that IE will play ball with it as posted, but Moz browsers need 'px' to be specified explicitly.
<script type="text/javascript">
<!--//
function setplay(thisfile,ww,hh) {
document.getElementById("MediaPlayer1").src=thisfile;
document.getElementById("MediaPlayer1").style.width=ww+'px';
document.getElementById("MediaPlayer1").style.height=hh+'px';
}
//-->
</script>
Alternatively, leave Bob's code as is giving you the freedom to call with setplay('myvid1.wmv', '320px', '240px'); ,
or setplay('myvid1.wmv', '100%', '100%'); ,
as required.
If width and height need calculating, then
var width = expression;
var height = expression;
setplay('myvid1.wmv', width+'px', height+'px');
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
<html>
<head>
<style type="text/css">
<!--
.fontStyle {
font-family: Verdana, Geneva, sans-serif;
font-size: small;
font-weight: bold;
color: #67A2DC;
}
-->
</style>
<script type="text/javascript">
window.onload=function(){
loadVideo();
}
function loadVideo()
{
if (parseInt(navigator.appVersion)>3)
{
if (navigator.appName == "Netscape")
{
winW = window.innerWidth;
winH = window.innerHeight;
}
if (navigator.appName.indexOf("Microsoft") != -1)
{
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
}
var dimW = winW-50;
var dimH = winH-20;
var w1 = dimW.toString();
var h1 = dimH.toString();
if(document.getElementById("vidEmbed") != null)
{
document.getElementById("vidEmbed").src = "Welcome_1.wmv";
document.getElementById("vidEmbed").style.width = w1;
document.getElementById("vidEmbed").style.height = h1;
}
else if(document.getElementById("Player") != null)
{
document.getElementById("Player").style.width = w1;
document.getElementById("Player").style.height = h1;
//document.getElementById("objectSrc").value = "Welcome_1.wmv";
document.getElementById("Player").url = "Welcome_1.wmv";}
}
</script>
</head>
<body><div>
<p><span class="fontStyle">Introduction
</span>
<object id="Player" width="100%" height="100%" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="border:0px;">
<param name="autoStart" value="True">
<param name="uiMode" value="full">
<param name="volume" value="50">
<param name="mute" value="false">
<param name="URL" id="objectSrc" value="">
<embed src="" id="vidEmbed" width="100%" height="100%" autostart="true" uimode="full" volume="50" mute="false"> </embed>
</object>
</p>
</div>
</body>
</html>
Removered lines!
Set the
<param name="uiMode" value="none">
If you don't want player controls to appear on your media.
Troy III
Practically a Master Poster
609 posts since Jun 2008
Reputation Points: 120
Solved Threads: 80
safari is apple,
if a mac does the mac have windows media installed
from the "get windows media player" link included in the original script, that part of it works anyway
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376