Avatar of incrediblejohn
incrediblejohn
 asked on

How can I dynamically change FlashVars item "streamName" at runtime using ASP.NET?

Trying to figure out how to reference the 2 streamName name/value pairs in the <object> and <embed tags> of a flash control on an .aspx page. I am trying to use asp.net to get the data from a table (no problem there) and put it in the value part of streamName FlashVar.

I can't seem to reference these tags, or insert script brackets inside of the <object> or <embed> tags.
I've tried <%# strstreamNameVariable %>. I could do it if I could get javascript to see these tags and their parameters.

Here is the flash control that works static ok on my webpage(the streamName is the onlything I need to change):

  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="300" id="FLVPlayer">
    <param name="movie" value="FLVPlayer_Progressive.swf" />
    <param name="salign" value="lt" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Clear_Skin_3&streamName=zydeco-example&autoPlay=false&autoRewind=true" />
    <embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Clear_Skin_3&streamName=zydeco-example&autoPlay=false&autoRewind=true" quality="high" scale="noscale" width="400" height="300" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />  
</object>
JavaScriptASP.NETWeb Development

Avatar of undefined
Last Comment
Bane83

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Bane83

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
incrediblejohn

ASKER
The embedded tags don't work no matter how I do it. I did end up with what you suggest (pretty much exactly like you say). I will award you the points, only fair. However, if I might squeeze a little more out of you:  I would like to serverside write these tags to javascript that then does a document.write or a document.getElementById("someSpanID").innerHTML= javscriptVariable. Can't seem to figure that one out. (body onload fill the span or something like that). Reason being is that I'm trying to avoid that annoying "click here to activate control" which happens unless you write the flash tags using javascript.

Here is my working code that models your soluton, thank you very much!
            Dim sbFlashPlayer As New StringBuilder

            'FOR IE BROWSERS
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            'FOR ALL OTHER BROWSERS
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)
            sbFlashPlayer.Append("")
            sbFlashPlayer.Append(Environment.NewLine)

            objFlash.Text = sbFlashPlayer.ToString
Bane83

You can have the literal contain a <script> tag with a single function which does a document.write() of each line in the code you posted.

An alternative method that I've found is to have a bit of script near the bottom of your page (say after the closing body tag and before the closing html tag) which does something like this:

var els = document.getElementsByTag('object')

for(i = 0; i < els.length; i++)
{
   els.outerHTML = els.outerHTML;
}

I've no idea why it works, but for some reason it does (I used it in a project a few months back).  You may have to do the same for the embeds.
incrediblejohn

ASKER
"I've no idea why it works"

Works for what? Getting rid of the "Click here to activate control".
Hope that is what you mean.
You have good ideas.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Bane83

Sorry, yeah it gets rid of the click here to activate.
incrediblejohn

ASKER
Yeah, this didn't work. Still have to click twice to start the flash:

  <script type="text/javascript">

    var els = document.getElementsByTag('object');

    for(i = 0; i < els.length; i++)
    {
       els.outerHTML = els.outerHTML;
    }
</script>  
Bane83

See the script below.

It does pretty much the same thing that your script does, however I have it in an external .js file which I reference on each page that needs it.  I believe at one point I tried putting it directly on the page and it wouldn't work for some reason, so try the script below in an external .js file.
if (navigator.appName == "Microsoft Internet Explorer") (function() {
        var onload = window.onload || function(){};
        if (document.body != null) 
        {
			document.body.setAttribute('onload', null);
        }
        window.onload = function() {
                onload.apply(this, arguments);
                var tags = ['object', 'embed', 'applet'];
                for( i=0; i<tags.length; i++ ) {
                        var elements = document.getElementsByTagName(tags[i]);
                        for(j=0; j<elements.length; j++)
                                elements[j].outerHTML = elements[j].outerHTML
                }
        }
})();

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
incrediblejohn

ASKER
Well, I think I should make this another question and award points if it is solved. The code below of yours that I used in a javascript file that is referenced at the bottom of my .aspx page returns the first 3 "hey" alerts. But does not return the last one alert("hey 4") and only a blank screen is displayed with or without the alerts.


alert("hey");
           if (navigator.appName == "Microsoft Internet Explorer") (function() {
                    var onload = window.onload || function(){};
                    if (document.body != null)
                    {
                   
                              document.body.setAttribute('onload', null);
                    }
                    window.onload = function() {
                            onload.apply(this, arguments);
                             alert("hey 2");
                            var tags = ['object', 'embed', 'applet'];
                            for( i=0; i
Bane83

Hmm, if nothing is showing up on the page, then it wouldn't get into the last "hey" since the source would appear to be empty.  Perhaps there's a malformed tag on the page which is causing it not to render anything?
incrediblejohn

ASKER
Well, I take out the script reference and then the page loads.
There is a macromedia flash version detector in the body onload already.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Bane83

That could be effecting it some how, I'm not sure.