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

允我心安 提交于 2020-01-06 19:10:50

问题


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.


回答1:


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 ?




回答2:


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:


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 :)



来源:https://stackoverflow.com/questions/13953236/cant-display-swf-files-on-a-page-with-httphandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!