Solved

media element and silverlight

Posted on 2009-07-05
6
847 Views
Last Modified: 2013-11-12
How do you create something like this with a media element?

http://narenda.com/silverlight/default.html

What I have so far is:


and I got this error:

Error: Unhandled Error in Silverlight 2 Application SlidingBlocks.xap
Code: 4001    
Category: MediaError      
Message: AG_E_NETWORK_ERROR    

Canvas[] cI = new Canvas[9];

        MediaElement[] me = new MediaElement[9]; 

         int blockSizeW = 97;

        int blockSizeH = 97;

 

int nx = 0;

            for (int ix = 0; ix < 3; ix++)

                for (int iy = 0; iy < 3; iy++)

                {

                    nx = (ix * 3) + iy;

                    me[nx] = new MediaElement();

                    me[nx].Height = 300;

                    me[nx].Width = 300;

                    me[nx].Stretch = Stretch.UniformToFill;

                    RectangleGeometry r = new RectangleGeometry();

                    r.Rect = new Rect((ix * blockSizeW), (iy * blockSizeH), blockSizeW, blockSizeH);

                    me[nx].Clip = r;

                    me[nx].Source = new Uri("assets/SharePoint.wmv", UriKind.Relative);

                    me[nx].SetValue(Canvas.TopProperty, Convert.ToDouble(iy * blockSizeH * -1));

                    me[nx].SetValue(Canvas.LeftProperty, Convert.ToDouble(ix * blockSizeW * -1));

                 

                    cI[nx] = new Canvas();

                    cI[nx].Width = blockSizeW;

                    cI[nx].Height = blockSizeH;

                    cI[nx].Children.Add(me[nx]);

                    cI[nx].SetValue(Canvas.NameProperty, "C" + nx.ToString());

                    cI[nx].MouseLeftButtonDown += new MouseButtonEventHandler(Page_MouseLeftButtonDown);

                    if (nx < 8)

                        GameContainer.Children.Add(cI[nx]);

                }

Open in new window

0
Comment
Question by:kuntilanak
  • 4
  • 2
6 Comments
 
LVL 1

Expert Comment

by:JaressLoo
ID: 24781852
The first thing you'll need is a reference to the Microsoft Silverlight dll (System.Web.Silverlight). You can download what you'll need from here: http://silverlight.net/GetStarted/

Then, you'll need the media player ASP.NET code that I've attached.

The way I usually do this is by opening up expression encoder and then encode a video with the player that I like. It outputs to you a completed HTML web page.

You can take what it provides and integrate it with the media player element that I've attached.

I'm also attaching the skin and javascripts that make my player work on this page: http://betatest1.jaressloo.com/tutorials/butterfly

I hope you find this helpful
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>
 

    <asp:ScriptManager ID="ScriptManager1" runat="server">

        <Scripts>

            <asp:ScriptReference Path="~/includes/MicrosoftAjax.js" />

            <asp:ScriptReference Path="~/includes/Silverlight.js" />

            <asp:ScriptReference Path="~/includes/SilverlightControl.js" />

            <asp:ScriptReference Path="~/includes/SilverlightMedia.js" />

            <asp:ScriptReference Path="~/includes/ExpressionPlayer.js" />

            <asp:ScriptReference Path="~/includes/PlayerStrings.js" />

            <asp:ScriptReference Path="~/includes/player.js" />

            <asp:ScriptReference Path="~/includes/StartPlayer.js" />

        </Scripts>

    </asp:ScriptManager>
 

<asp:MediaPlayer ID="mpVideo" runat="server" Height="400px" Width="530px" MediaSource="../videos/Butterfly.wmv"  

  MediaSkinSource="../includes/player.xaml" ScaleMode="Stretch">

</asp:MediaPlayer>

Open in new window

ExpressionPlayer.js.txt
MicrosoftAjax.js.txt
player.js.txt
player.xaml.txt
PlayerStrings.js.txt
Silverlight.js.txt
SilverlightControl.js.txt
SilverlightMedia.js.txt
StartPlayer.js.txt
0
 

Author Comment

by:kuntilanak
ID: 24782022
isn't there a simple way to do this using a media element? and a canvas?
0
 
LVL 1

Expert Comment

by:JaressLoo
ID: 24782145
You don't have to use all of the scripts in the script manager.

You can just use the media element. That should work.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:kuntilanak
ID: 24782162
Yes, but how do I use the media element?? Can you tell why my code doesn't work?
0
 
LVL 1

Expert Comment

by:JaressLoo
ID: 24782202
Unfortunately, no. When I create a media element in a page I literally just drag the media element from the toolbox onto the page in VS and it just works.

This looks like server-side coding that I don't need to do nor have I ever done.

Sorry I couldn't be of more help!

Have you downloaded the silverlight SDK from Microsoft?
0
 
LVL 1

Accepted Solution

by:
JaressLoo earned 500 total points
ID: 24783268
I just added a media element from scratch and these were the steps taken:

1) Checked to see if I had the SP1 for VS2008. I did not have it, so I downloaded from here: http://www.microsoft.com/downloads/details.aspx?familyid=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en

 - Installed SP1

2) Downloaded and installed Silverlight SDK for VS2008 SP1 from here: http://www.microsoft.com/downloads/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&displaylang=en

3) Opened VS2008 and created a new "ASP.NET Web Site"

4) Dragged a "ScriptManager" element from the toolbox onto the page.

5) Dragged a MediaPlayer element from the toolbox onto the page.

6) Added a video in wmv format into my website directory

7) Set the reference to the video in the "MediaSource" attribute of the asp:MediaPlayer node.

8) Build and run.

9) It works!

Attached is the code I used. Note: There is NO code behind or server side programming required...
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"

    TagPrefix="asp" %>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <div>

        <asp:MediaPlayer ID="MediaPlayer1" MediaSource="~/Butterfly_OLD.wmv" runat="server" Height="240px" Width="320px">

        </asp:MediaPlayer>

    </div>

    </form>

</body>

</html>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET reading ATOM 2 51
LINQ - C# to VB convertion 12 46
Why is some text in blue in Visual Studio? 6 22
Adware on IIS hosted asp.net website 1 15
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now