473,696 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Silverlight video doesn't work when file is streamed from handler

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="vid eo2.aspx.cs"
Inherits="WebAp plication2.vide o2" %>

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

<script type="text/javascript">
//<![CDATA[
Sys.UI.Silverli ght.Control.cre ateObject('mp1p ', '\u003cobject
type="applicati on/x-silverlight" id="MediaPlayer 1"
style="height:2 40px;width:320p x;">\r\n\t\u003 ca
href="http://go2.microsoft.c om/fwlink/?LinkID=114576& v=1.0">\u003cim g
src="http://go2.microsoft.c om/fwlink/?LinkID=108181" alt="Get Microsoft
Silverlight" style="border-width:0;" />\u003c/a>\r\n\u003c/object>');
Sys.Application .initialize();
Sys.Application .add_init(funct ion()
{
// This works:
$create(Sys.UI. Silverlight.Med iaPlayer, { "mediaSourc e":
"video/3StrikesChipmun k_56.wmv", "scaleMode" : 1, "source":
"skins/mediaplayer/Professional.xa ml" }, null, null, $get("mp1p"));

// This does not work (only difference is that it gets the video from the
handler)
//$create(Sys.UI. Silverlight.Med iaPlayer, { "mediaSourc e":
"handler/getmediaobject. ashx", "scaleMode" : 1, "source":
"skins/mediaplayer/Professional.xa ml" }, null, null, $get("mp1p"));
});
//]]>
</script>
</form>
</body>
</html>

----------------------------------------
This page works great when I directly reference the video file. But when I
try to use an HTTP handler instead, all I get is an empty Silverlight control
with the Play button disabled and no video. You can repro it by commenting
out the $create line above that references the WMV file and uncomment the
line below it that uses the getmediaobject. ashx handler.

The getmediaobject. ashx handler is straight forward:

using System.IO;
using System.Web;
using System.Web.Sess ionState;

namespace WebApplication2 .handler
{
[System.Web.Serv ices.WebService (Namespace = "http://tempuri.org/")]
[System.Web.Serv ices.WebService Binding(Conform sTo =
System.Web.Serv ices.WsiProfile s.BasicProfile1 _1)]
public class getmediaobject : IHttpHandler
{
#region IHttpHandler Members

public bool IsReusable
{
get { return true; }
}

public void ProcessRequest( HttpContext context)
{
ProcessMediaObj ect(context,
context.Server. MapPath("~/video/3StrikesChipmun k_56.wmv"));
}

#endregion

private void ProcessMediaObj ect(HttpContext context, string filePath)
{
FileStream fileStream = null;
try
{
context.Respons e.Clear();
context.Respons e.ContentType = "video/x-ms-wmv";
context.Respons e.Buffer = false;

HttpCachePolicy cachePolicy = context.Respons e.Cache;
cachePolicy.Set Expires(System. DateTime.Now.Ad dSeconds(259200 0)); // 30
days
cachePolicy.Set Cacheability(Ht tpCacheability. Public);
cachePolicy.Set ValidUntilExpir es(true);

const int bufferSize = 32768;
byte[] buffer = new byte[bufferSize];
long byteCount;
fileStream = File.OpenRead(f ilePath);
while ((byteCount = fileStream.Read (buffer, 0, buffer.Length)) 0)
{
if (context.Respon se.IsClientConn ected)
{
context.Respons e.OutputStream. Write(buffer, 0, buffer.Length);
context.Respons e.Flush();
}
else
{
return;
}
}
}
finally
{
if (fileStream != null)
fileStream.Clos e();

context.Respons e.End();
}
}
}
}

The really odd part is that the handler *does* work on my local network - it
only
fails when I publish the code to a web server and then access the page
across the internet. It happens on both IIS 6 and IIS 7, and in IE and
Firefox.

I published the above code at
http://www.galleryserverpro.com/dev/webapp2/video2.aspx. The page is
currently configured to use the handler so that you can see it failing for
yourself.

Additional info:
1. I am using the final release of 2.0 Silverlight, including the two script
files SilverlightCont rol.js and SilverlightMedi a.js.
2. I have confirmed that no exception is occuring in the handler.
3. Using Firebug I can confirm that the handler is being called and that it
is returning data to the browser.

All evidence points to Silverlight not being able to handle the data
streamed from Silverlight. Perhaps there is a change I can make to the
handler to get it to work, or maybe there is an issue within Silverlight.
Please advise.

Thanks!
Roger Martin
Nov 5 '08 #1
0 3601

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

Similar topics

5
5458
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
1871
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.
0
2369
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
I have a web site under .NET 2.0 that renders videos using the Silverlight media player. The <asp:MediaPlayercontrol 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="video5.aspx.cs" Inherits="GalleryServerPro.Web.video5" %>
1
2849
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
3541
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
4002
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
7152
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
8647
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
8667
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
8597
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
9012
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6515
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
5857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4611
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3034
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2319
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1992
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.