Can't display .swf files on a page with httpHa

2019-08-29 10:55发布

Read the last EDIT, please.

I have a page in which I should display some media data. For this I'm using html tag, like this:

<object type="video/x-ms-wmv" width="320" height="240">
    <param name="src" value="some_media_url" />
    <param name="AutoSize" value="true">
    <param name="ShowDisplay" value="false">
    <param name="AutoStart" value="false">
    <param name="StretchToFit" value="true">
    <param name="bgcolor" value="#ffffff" />
</object>

In my case, I should get media data from SQL server by some MediaHandler.ashx http handler. When I get an audio(.mp3, .wma) or video(.flv, .mp4) stream this works fine. But I'm getting some problems with .swf flash files. For this type of files I change <object> type to be "application/x-shockwave-flash". In this case when I use some remote path, like http://www.tizag.com/pics/example.swf, it works fine:

<object type="application/x-shockwave-flash" width="320" height="240">
    <param name="src" value='http://www.tizag.com/pics/example.swf' />
    <param name="AutoSize" value="true">
    <param name="ShowDisplay" value="false">
    <param name="AutoStart" value="false">
    <param name="StretchToFit" value="true">
</object>

But, it doesn't work with my handler. It neither works with local paths,like "c:\videos\example.swf"

Any idea?

EDIT: Actually src for media looks like this:

<object type="video/x-ms-wmv" width="320" height="240">
    <param name="src" value="http://localhost:11111/MediaHandler.ashx?Id=1111" />
    <param name="AutoSize" value="true">
    <param name="ShowDisplay" value="false">
    <param name="AutoStart" value="false">
    <param name="StretchToFit" value="true">
    <param name="bgcolor" value="#ffffff" />
</object>

EDIT:

This works fine, if I directly refer to an existing file:

 <object type="application/x-shockwave-flash" width="320" height="240">
        <param name="src" value="/videos/ETFflash1016.swf" />
        <param name="AutoSize" value="true">
        <param name="ShowDisplay" value="false">
        <param name="AutoStart" value="true">
        <param name="StretchToFit" value="true">
    </object>

But when I use httpHandler to get file from DB:

<object type="application/x-shockwave-flash" width="320" height="240">       
    <param name="src" value="http://localhost:57031/MediaHandler.ashx?Id=512429" />
    <param name="AutoSize" value="true">
    <param name="ShowDisplay" value="false">
    <param name="AutoStart" value="true">
    <param name="StretchToFit" value="true">
</object>

flash is not displayed.

I've compared the output html for these cases, they're the same in both cases (except src param value). Fiddler shows the same result for both requests for .swf file and the browser shows(e.g. in IE dev tool's Netwok tab) that the file was downloaded to client in both cases. BUT in the case with the handler, flash is not being displayed.

3条回答
贪生不怕死
2楼-- · 2019-08-29 11:25

try this:

<object type="application/x-shockwave-flash" data="file.swf" style="width:640px;height:480px;margin:10px 36px;">
<param name="movie" value="file.swf" />
<param name="AutoSize" value="true">
<param name="ShowDisplay" value="false">
<param name="AutoStart" value="false">
<param name="StretchToFit" value="true">
<param name="bgcolor" value="#ffffff" />
</object>

it worked for me

查看更多
劫难
3楼-- · 2019-08-29 11:27

Fiddler shows the same result for both requests for .swf file

In Fiddler, Response Headers, do both the local file and ASHX handler return the same Content-Type: application/x-shockwave-flash ?

查看更多
叛逆
4楼-- · 2019-08-29 11:43

I've solved it!

In the handler, I was setting Response Header's parameters the same values as they were in the case with directly referring to an existing file.

Now, I just removed all this values, and it works! I still can't understand why, but it works :)

查看更多
登录 后发表回答