Re: [SWFObject] Debugging IE problem?

422 views
Skip to first unread message
Message has been deleted

Aran Rhee

unread,
Sep 25, 2012, 2:46:22 PM9/25/12
to swfo...@googlegroups.com
Hi Jeff.

So I ran your page in IE8. It got a js error :

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Tue, 25 Sep 2012 18:42:31 UTC

Message: 'console' is undefined
Line: 23
Char: 4
Code: 0


:) Good old IE eh?

I'd say remove your console statement, and you should be all good. I'd suggest enabling IE's Developer tools (like Firebug, only not a s good - F12 or tools > developor tools), so that you can see what is going on


BTW - Did you know SWFobject already has a querystring util method for you to use? ( http://code.google.com/p/swfobject/wiki/api -
swfobject.getQueryParamValue(paramStr) ). If you do not know in advance what you want to pass to your swf, then your looping method would be better, otherwise this one could be handy.


Cheers,
Aran



On Fri, Sep 21, 2012 at 7:29 PM, Jeff <kr...@responsive.net> wrote:
Hello,

I want to play multiple SWFs on a common page opened from linked pages using query strings which indicate the SWF to play. I've uploaded a demonstration link to http://responsive.net/accounting5/testLink.html . My sample SWF plays in all Flash enabled browsers except IE. Any suggestions for how I might debug this problem?

Our goal is default SWF movies with html5 fallbacks. I've got both parts working in every browser except for SWFs in IE.

Thanks in advance...
-Jeff


--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/h3XwgnULh2IJ.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.

Jeff

unread,
Sep 25, 2012, 7:31:05 PM9/25/12
to swfo...@googlegroups.com
Hey thanks! Its hard to imagine a helpful statement in one debugging tool would be a liability in the next. I will look into the query method you gave.

-grateful newbie

Jeff

unread,
Sep 27, 2012, 12:20:18 PM9/27/12
to swfo...@googlegroups.com
To anyone who is interested, I've updated my demonstration page with alternative html5 video for the Flash haters. I am open to your critique. 

Alternative content for the deaf, dumb, blind kid is not provided. If you had suggestions, I am all ears. To my knowledge neither <object> nor <video> supports the <alt> and <longdesc> attributes.

Here is my code for reference:

Link Page:
<body>
<a href="Test.html?mTitle=Cash%20Flow&mFile=cashFlows1&mHeight=400&mWidth=550" target="new">Test Link</a>
</body>

Target Page:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Legacy SWF Player with HTML5 fallback</title>
<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript">
//create query string object
var movieDetails = {};
decodeQuery();
function decodeQuery() {
  var match,
pl     = /\+/g,
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query  = window.location.search.substring(1);
  while (match = search.exec(query))
movieDetails[decode(match[1])] = decode(match[2]);
}
//activate swf movie details
function swfPlay (){
  var flashvars = {};
  var params = {};
  var attributes = {};
  document.getElementById("swfMovie").style.display = "block";
  swfobject.embedSWF("video/"+movieDetails.mFile+".swf", "swfMovie", movieDetails.mWidth, movieDetails.mHeight, "8.0.0", false, flashvars, params, attributes);
}
//activate alternative html5 content
function html5play (){
  document.getElementById("html5").style.display = "block";
  document.getElementById("3").height = movieDetails.mHeight;
  document.getElementById("3").width = movieDetails.mWidth;
  document.getElementById("mac").src = "video/"+movieDetails.mFile+".mp4";
  document.getElementById("chrm").src = "video/"+movieDetails.mFile+".webm";
  document.getElementById("fox").src = "video/"+movieDetails.mFile+".ogv";
}
</script>
</head>
<body>
  <h1 id="Title">Template</h1>
  <div align="center" class="movie">
    <div id="swfMovie" style="display:none">
        <h4>Videos on this page require Adobe Flash Player,<br><br>or an html5 enabled browser.</h4>
            <a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33"></a>
    </div>
    <div id="html5" style="display:none">
      <video id="3" controls="controls">
        <source id="mac" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
        <source id="chrm" type='video/webm; codecs="vp8, vorbis"' />
        <source id="fox" type='video/ogg; codecs="theora, vorbis"' />
        <h4>Videos on this page require an html5 enabled browser,<br><br>or Adobe Flash Player.</h4>
        <a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33"></a>
      </video>
    </div>  
  </div>
  <br><hr>
  <script type="text/javascript">
  //modify h1 header
  document.getElementById("Title").innerHTML=movieDetails.mTitle;
  //determine if Flash is loaded
  if(swfobject.hasFlashPlayerVersion("1")){
    swfPlay ();
  }else{
    html5play ()
  }
  </script>
  </body>

Aran Rhee

unread,
Sep 27, 2012, 12:44:16 PM9/27/12
to swfo...@googlegroups.com
A few things which I think could be improved:

1) Flash version detection - You do not want to detect just for version 1. It needs to be the minimum version capable of playing back your video (most likely 9.0, which added AS3 and h264 support)

2) init - You are not deciding on whether to display Flash or HTML5 until after the whole page has loaded. You can do this decision and write out the appropriate DOM nodes much earlier (ondomready).

Something like:

<head>
...

function doVideoCheck(){
if (swfobject.hasFlashPlayerVersion("9.0")) {
  swfPlay();
}
else {
 html5play();
}
 
}

...

swfobject.addDomLoadEvent(doVideoCheck); 
</head>


3) construct DOM nodes rather than defining hidden content - No point writing stuff to the page which is never going to be used / seen. If you detect HTML5 rather than Flash, construct your nodes as required, setting the sources etc, and then write it into the same parent div as where the flash object would have been written using createElement.


Cheers,
A






--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/taxqfKnSDlIJ.

Jeff

unread,
Sep 28, 2012, 5:23:03 PM9/28/12
to swfo...@googlegroups.com
Thanks again for your help Misterhee. Your critique points to my lack of knowledge as a programmer. I am relying on SWFobject to do the Flash detection--if any version of flash player is active in the browser. I've also used hidden html elements to minimize demands on my JavaScript skills. As a result, I needed to call my functions after loading the html elements they would modify. Sources were not defined my html, so I see little to gain from using createElement for this particular application. I will however experiment with the method--since you've gone to the trouble of suggesting it.

-Jeff

Aran Rhee

unread,
Sep 28, 2012, 6:31:46 PM9/28/12
to swfo...@googlegroups.com
Hi Jeff

At the end of the day, use what you can to get the job done (and learn a bit as you go along). What you posted looked like it would work, but you did ask for a critique :)

the createElement suggestion was really about not writing content if it is not required. If you do detect you need to use /construct the html5 player, then you can add your sources at the node creation time (as opposed to setting them afterwards like you are doing now). No big deal here - you can do it either way...

Go well on the project.


Cheers,
A


On Fri, Sep 28, 2012 at 4:23 PM, Jeff <kr...@responsive.net> wrote:
Thanks again for your help Misterhee. Your critique points to my lack of knowledge as a programmer. I am relying on SWFobject to do the Flash detection--if any version of flash player is active in the browser. I've also used hidden html elements to minimize demands on my JavaScript skills. As a result, I needed to call my functions after loading the html elements they would modify. Sources were not defined my html, so I see little to gain from using createElement for this particular application. I will however experiment with the method--since you've gone to the trouble of suggesting it.

-Jeff

--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/WBiA9I4Ok7oJ.
Reply all
Reply to author
Forward
0 new messages