473,748 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Silverlight video doesn't work when file is streamed from ASHX han

I have a web site under .NET 2.0 that renders videos using the Silverlight
media player. The <asp:MediaPlaye rcontrol only works on .NET 3.5, but I
managed to get things working under .NET 2.0 by working with the javascript
rather than the server control.

The web page looks like this:

<%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="vid eo5.aspx.cs"
Inherits="Galle ryServerPro.Web .video5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html id="html" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptMana ger ID="ScriptManag er1" runat="server">
<Scripts>
<asp:ScriptRefe rence Path="~/script/Silverlight.js" />
<asp:ScriptRefe rence Path="~/script/SilverlightCont rol.js" />
<asp:ScriptRefe rence Path="~/script/SilverlightMedi a.js" />
</Scripts>
</asp:ScriptManag er>
<asp:PlaceHolde r ID="phContent" runat="server" />
</form>
</body>
</html>

The code behind:

using System;
using System.Web.UI;

namespace GalleryServerPr o.Web
{
public partial class video5 : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
phContent.Contr ols.Add(new LiteralControl( "<div id=\"mp1p\" />"));

// Specify direct path to media file. This works.
string script = "Sys.UI.Silverl ight.Control.cr eateObject('mp1 p', '<object
type=\"applicat ion/x-silverlight\" data=\"data:app lication/x-silverlight,\"
id=\"mp1\" style=\"height: 400px;width:500 px;\"><param name=\"Windowle ss\"
value=\"True\" /><a
href=\"http://go2.microsoft.c om/fwlink/?LinkID=114576& v=1.0\"><img
src=\"http://go2.microsoft.c om/fwlink/?LinkID=108181\ " alt=\"Get Microsoft
Silverlight\" style=\"border-width:0;\"
/></a></object>');Sys.A pplication.init ialize();Sys.Ap plication.add_i nit(function()
{ $create(Sys.UI. Silverlight.Med iaPlayer,
{\"mediaSource\ ":\"mediaobject s/3StrikesChipmun k_56.wmv\",\"sc aleMode\":1,\"s ource\":\"skins/mediaplayer/Professional.xa ml\"
}, null, null, $get(\"mp1p\")) ; });";

// Specify path to media file via ASHX handler. This does not work.
string scriptWithHandl er =
"Sys.UI.Silverl ight.Control.cr eateObject('mp1 p', '<object
type=\"applicat ion/x-silverlight\" data=\"data:app lication/x-silverlight,\"
id=\"mp1\" style=\"height: 400px;width:500 px;\"><param name=\"Windowle ss\"
value=\"True\" /><a
href=\"http://go2.microsoft.c om/fwlink/?LinkID=114576& v=1.0\"><img
src=\"http://go2.microsoft.c om/fwlink/?LinkID=108181\ " alt=\"Get Microsoft
Silverlight\" style=\"border-width:0;\"
/></a></object>');Sys.A pplication.init ialize();Sys.Ap plication.add_i nit(function()
{ $create(Sys.UI. Silverlight.Med iaPlayer,
{\"mediaSource\ ":\"/dev/gs/handler/getmediaobject. ashx?OG/v3eAwpo3M6STSva 1cvgMqg4K8r1clw FvPuAJQ4YnG7Jcg/xqOru3otGjczWUC t1jB0uimLyDAnGy eGGKVqtng8JweBY 9ZkrDcM3bfDbcP4 tGfdq9QHP41oV6k 5UBDncTxlr3iZTb yiVeDTAkfp9Ts7b FAHk+n\",\"scal eMode\":1,\"sou rce\":\"skins/mediaplayer/Professional.xa ml\"
}, null, null, $get(\"mp1p\")) ; });";

ScriptManager.R egisterStartupS cript(this, typeof(GspPage) ,
"startupScript" , scriptWithHandl er, true);
}
}
}

The AXHX handler (I include only the relevant method as the rest of the code
in the handler deals with security and would distract):

private void ProcessMediaObj ect()
{
// Send the specified file to the client.
FileStream fileStream = null;
try
{
IMimeType mimeType = MimeType.LoadIn stanceByFilePat h(this._filenam e);

this._context.R esponse.Clear() ;
this._context.R esponse.Content Type = mimeType.FullTy pe;
this._context.R esponse.Buffer = false;

HttpCachePolicy cachePolicy = this._context.R esponse.Cache;
cachePolicy.Set Expires(System. DateTime.Now.Ad dSeconds(259200 0)); // 30 days
cachePolicy.Set Cacheability(Ht tpCacheability. Public);
cachePolicy.Set ValidUntilExpir es(true);

int bufferSize =
GalleryServerPr o.Web.WebsiteCo ntroller.GetGal leryServerProCo nfigSection().C ore.MediaObject DownloadBufferS ize;
byte[] buffer = new byte[bufferSize];
long byteCount;
fileStream = File.OpenRead(t his._filepath);
while ((byteCount = fileStream.Read (buffer, 0, buffer.Length)) 0)
{
if (this._context. Response.IsClie ntConnected)
{
this._context.R esponse.OutputS tream.Write(buf fer, 0, buffer.Length);
this._context.R esponse.Flush() ;
}
else
{
return;
}
}
}
catch (Exception ex)
{
GalleryServerPr o.ErrorHandler. AppErrorHandler .RecordErrorInf o(ex);
}
finally
{
if (fileStream != null)
fileStream.Clos e();

this._context.R esponse.End();
}
}

The ContentType of the Response is being set to "video/x-ms-wmv".

As long as I specify the path to the video file directly, everything works.
But when I try to use the handler to send the video to the browser, all I get
is an empty media player - I can see the play/pause/other controls but there
is no video.

The really odd part is that I *can* use the handler on my dev PC - it only
fails when I publish the code to the hosting company (Discount ASP.NET). It
happens on both IIS 6 and IIS 7.

I know you are not in the business of providing support for hosting
companies, so my question is: What could possibly be different on the server
that would cause this to fail? I verified that XAML is a valid MIME type.
Aug 19 '08 #1
0 2373

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5462
by: jen_designs | last post by:
How do I create custom controls for an embeded video. I need stop, play, pause, etc. Any thoughts?
4
1876
by: Ronald S. Cook | last post by:
I'm a Visual Studio developer confused by seeing these new products coming out... Expression and Silverlight. Is Expression maybe a successor to FrontPage and is Silverlight maybe something to compete with Flash? Are Visual Studio, Expression, and Silverlight expected to exists together (and in some sort of harmony) in a development shop, or is something else going on.
1
2855
by: Faisal Shafiq | last post by:
I want to upload a file direct to the Silverlight Streaming Service from a Web Client such as silverlight application. As per our product requirement we want to upload a .WMV file directly from silverlight client to Silverlight streaming service. I tried to user WebClient and HttpWebRequest for that purpose but, unfortunately I can found the way to do so. There are some problems with both classes. 1. There is no property of get...
3
3546
by: AliR \(VC++ MVP\) | last post by:
Hi Everyone, I have written a silverlight application, which talks to a WCF service, which was created within the website after watching this video: http://silverlight.net/learn/learnvideo.aspx?video=47177 The service gathers some data using a class library. This all works fine within Visual Studio, but when published to a web server it throws an excpetion, in the first xxxxServiceComplete call back, which
3
689
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
Note: My apologies for repeating this post from last week, but my nospam alias and profile account were incorrect. I think I have fixed this, so hopefully this post will trigger MS into a response per their MSDN policy. -------------------- I have a web site under .NET 2.0 that renders videos using the Silverlight media player. The web page looks like this: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="video2.aspx.cs"
13
4012
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.framework.aspnet&mid=e9a38d03-83a8-41fc-8950-5ee60d2a18a5. I have a web site under .NET 2.0 that renders videos using the Silverlight media player. When I stream the video file (.wmv) to the browser via a hard-coded link to the file,...
7
7155
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and Silverlight 2.0. To get these tools please visit this page Get Started : The Official Microsoft Silverlight Site and follow Step 1. Occasionally you find the need to have users upload multiple files at once. You could use multiple FileUpload...
3
8650
by: pavanip | last post by:
Hi, I am new to Silverlight application.I want to display video using Mediaelement tag and I used the below code to play video. <Canvas> <MediaElement x:Name="mPlayer" Width="640" Height="480" Source="a_video.avi"/> <Button x:Name="bPlay" Background="Green" Width="100" Height="45" Canvas.Left="8" Canvas.Top="497" Content="Play" /> <Button x:Name="bPause" Background="Yellow" Width="100" Height="45"...
0
8982
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9528
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9309
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9234
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4591
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.