Media Player in silverlight 2.0
Last post 05-10-2008 6:35 PM by Alan Cobb. 13 replies.
Sort Posts:
03-11-2008 1:51 AM
Media Player in silverlight 2.0

Need C# code to develop media player in silverlight 2.0

pradhakrishna284

Joined on 05-22-2007
Posts 18
03-11-2008 2:06 AM
Re: Media Player in silverlight 2.0

pradhakrishna284:
Need C# code to develop media player in silverlight 2.0
 

Why? Are you not happy with MediaElement, Video.Show, asp:MediaPlayer?

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
03-11-2008 3:07 AM
Re: Media Player in silverlight 2.0

I am using silverlight2.0 for user interface but the functionality should be in C#. For example the code for "Play button" should be written in C#.

pradhakrishna284

Joined on 05-22-2007
Posts 18
03-11-2008 4:20 AM
Marked as Answer
Re: Media Player in silverlight 2.0

pradhakrishna284:
I am using silverlight2.0 for user interface but the functionality should be in C#. For example the code for "Play button" should be written in C#.
 

You can use MediaElement to display the video. You can add the button as "play button" and you can manually play the video from C# code.

For example:

XAML  

  <MediaElement 
x:Name="butterflyMediaElement"
Source="sampleMedia/Butterfly.wmv" IsMuted="True"
Opacity="0.0" IsHitTestVisible="False" />

C# 

public void PlayMedia(object sender, MouseEventArgs e)
{
butterflyMediaElement.Play();
}

Please take a look this doc.  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
03-12-2008 1:44 AM
Re: Media Player in silverlight 2.0

Hi mchlSync,

                    First of all thanks for your answer. Well could you help me to get the full functionality of the silverlight2.0 media player. It should work in the same as windows media player.

 

Thank you

 

pradhakrishna284

Joined on 05-22-2007
Posts 18
03-12-2008 2:49 AM
Re: Media Player in silverlight 2.0

Hi,

I wish I would but I'm very busy with my full-time jobs, participating in this forum, writing stuffs in my blogs. Another thing is that there are a lot of samples and you can probably google it if you want. "Googling Silverlight Media Player" or "Video.Show". Sorry about that. Anyway, You can come back anytime and ask the question if you have some problems in creating your own player.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
03-12-2008 3:20 AM
Re: Media Player in silverlight 2.0

Hi,

  I have tried in google for free samples on silverlight2.0 media player. I could not find them.

Could you please create a sample application on silverlight2.0 media player(required functionality only in c#).

Play, Stop, Pause, Next video, etc.

 

pradhakrishna284

Joined on 05-22-2007
Posts 18
03-12-2008 11:09 AM
Re: Re: Media Player in silverlight 2.0

where are you coding the event? I am trying to find the silver liht eq of

Object.event += this method?

johnbail

Joined on 02-28-2008
Posts 9
03-12-2008 11:24 AM
Re: Media Player in silverlight 2.0

pradhakrishna284:
Could you please create a sample application on silverlight2.0 media player(required functionality only in c#).
 

It's simple. 

Play (C# code)

yourMediaElement.Play();

Stop (C# code)

yourMediaElement.Stop();
Pause (C# code) 
yourMediaElement.Pause();
Next (C# code) 
yourMediaElement.Stop();
yourMediaElement.Source = new Uri("myvideo2.wmv", UriKInd.Relative); // Not sure. you have to check the syntax.
yourMediaElement.Play();
 
 
 

 

 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
03-13-2008 2:07 AM
Re: Re: Media Player in silverlight 2.0

Hi 

Media Player is not getting displayed in the output.

 http://localhost:3207/SilverlightApplication1_Web/SilverlightApplication1TestPage.aspx

The following is in the Page.Xaml

 

<UserControl x:Class="SilverlightApplication1.Page"

xmlns="http://schemas.microsoft.com/client/2007"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Width="700" Height="400" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<Grid x:Name="LayoutRoot" Background="White">

<Canvas x:Name="playerCanvas" Canvas.Left="0" Canvas.Top="0" Width="392" Height="280">

 

<MediaElement x:Name="VideoStream" IsMuted="True" Opacity="0.0" IsHitTestVisible="False"

Width="200" Height="200"></MediaElement>

 

<Button Height="45.1" Width="60"

HorizontalAlignment="Left"

Canvas.Left="40"

Canvas.Top="290"

Content="Play"

Click="btnPlay_Click">

<Button.Background>

<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

<GradientStop Color="#FF000000"/>

<GradientStop Color="#FF1BB8DA" Offset="1"/>

</LinearGradientBrush>

</Button.Background>

</Button>

 

 

</Canvas>

pradhakrishna284

Joined on 05-22-2007
Posts 18
03-13-2008 2:09 AM
Re: Re: Media Player in silverlight 2.0

Hi

 

MediaElement(media player)  is not getting displayed in the output when i am using silverlight 2.0

pradhakrishna284

Joined on 05-22-2007
Posts 18
03-13-2008 2:21 AM
Re: Re: Media Player in silverlight 2.0

pradhakrishna284:
<MediaElement x:Name="VideoStream" IsMuted="True" Opacity="0.0" IsHitTestVisible="False"

Width="200" Height="200"></MediaElement>

 

Where is your source?

Example: 

  <MediaElement 
x:Name="butterflyMediaElement"
Source="sampleMedia/Butterfly.wmv" IsMuted="True"
Opacity="0.0" IsHitTestVisible="False"

 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
05-08-2008 10:49 PM
Re: Re: Media Player in silverlight 2.0

Hi,

  I am trying to play a video using silverlight 2.0 beta. The video is to be played using rstp protocol . I am using the following snippet.

<MediaElement Source="rtsp://wm9.streaming.telstra.com/wh_aflfilms0/OnDemand/2008/on/competition/rd1/BB_moty_rd1_cleve_hughes.wmv" Opacity="1.0" Canvas.Left="0" AutoPlay="True" Canvas.Top="0" ></MediaElement>

Please  suggest why this does not work.

Thanks.

Iluvcsharp

Joined on 05-09-2008
Posts 1
05-10-2008 6:35 PM
Re: Re: Media Player in silverlight 2.0

Hi Iluvvcsharp,

The RTSP streaming protocol is not supported (even in the SL2 final release version apparently?).  See: http://silverlight.net/forums/p/586/972.aspx#972 (Only HTTP streaming is supported).

Alan Cobb
www.alancobb.com/blog (Silverlight blog)

Alan Cobb

Joined on 04-30-2007
Northern California, USA
Posts 111