1

私はSQL Server 2008でFilestreamを使用して、asp.net Webアプリから画像とビデオファイルを保存しています。これまでのところ、いくつかの画像とビデオ ファイルをアップロードして、Filestream 対応の SQL サーバー データベースに保存することができます。

しかし、画像ファイルとビデオ ファイルの両方をアプリケーションに表示したい場合。画像ファイルを取得して、アプリケーションで表示できます。しかし、ビデオ ファイルを取得してアプリケーションから JW Player で再生することができません。

これまでのところ、次のことを行っています。 gridview コントロールを含む .aspx Web フォームがあります。この Web フォームのコード ビハインドでは、次のように gridview コントロールのデータをバインドしています。

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["tmmaConnectionString"].ConnectionString);
        SqlCommand command = new SqlCommand("SELECT ID, ProgramTitle,ProgramVideoName, ProgramId from [tblProgramContent] where programId="+progId, connection);
        SqlDataAdapter ada = new SqlDataAdapter(command);
        ada.Fill(dt);
        GVVideos.DataSource = dt;
        GVVideos.DataBind();

私のグリッドビューコントロールは次のようになります

    <asp:GridView ID="GVVideos" runat="server" AutoGenerateColumns="false">
            <Columns>
                 <asp:BoundField HeaderText = "Program File Name" DataField="ProgramVideoName" />
                <asp:BoundField HeaderText = "Program Title" DataField="ProgramTitle" />
                <asp:TemplateField HeaderText="Program Video">
                <ItemTemplate>
                     <!--<asp:Image ID="Image1" runat="server" ImageUrl='<%= "GetProgram.ashx?prog-Id="+ Eval("ProgramId") %>'/>
                      <asp:LinkButton ID="lbGetFile" runat="server" CommandName="GetFile" CommandArgument='<%#Eval("ProgramId") %>' ><img src='<%#Eval("ProgramId") %>.jpg' /></asp:LinkButton>-->
                   <div id="play-video" >
                      <a href="" id="play-prog">  <%#Eval("ProgramVideoName") %> </a>
                      <embed
                            flashvars="file=<%# "GetProgram.ashx?prog-Id="+ Eval("ProgramId") %> "
                            allowfullscreen="true"
                            allowscripaccess="always"
                            id="player1"
                            name="player1"
                            src="Scripts/jwplayer/player.swf"
                            width="200"
                            height="180"
                        /> 
                        </div>
                </ItemTemplate>
             </asp:TemplateField>
</Columns>
        </asp:GridView>

program-id を受け取る HTTP ハンドラーを渡し、<%# "GetProgram.ashx?prog-Id="+ Eval("ProgramId") %>対応するビデオ ファイルをクライアントに返します。ただし、これはビデオ ファイルを返さず、JW プレーヤーに埋め込みます。これを行うためのより良い方法はありますか、または上記のサンプル プログラムにどのような変更を加える必要がありますか?

4

0 に答える 0