C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Silverlight »

Media element fullscreen


Posted Date: 08 Oct 2009      Posted By: NekkantiDivya      Member Level: Gold     Points: 1   Responses: 2



Hi,

I am working on a silverlight project. In this I have a media element in silvelight usercontrol. I am using this user control in MainPage.xaml. In the user control I have a button the media element should be fullscreened and then if I click Escape it should return to its original size.

If anyone have any idea to do this please reply me.


Thanks in advance.





Responses

Author: Lalji    12 Oct 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Media Element Fullscreen in Silverlight code sample

Its often required to enable the fullscreen feature of an media element in silverlight. There is no straight forward way to enable that. Rather, use a video brushing, which brush the screen with the current video.

Use the xaml code as follows :

<MediaElement x:Name="media" Stretch="Uniform" Visibility="Collapsed"/>

<Rectangle x:Name="rectVideoBrush" Stretch="Uniform" Visibility="Collapsed">

<Rectangle.Fill>

<VideoBrush x:Name="mediaBrush" SourceName="media" Stretch="Uniform"/>

</Rectangle.Fill>

</Rectangle>

"media" is the media element which is set the source of the video brush named “mediaBrush”. On the full screen event trigger. the video brush brushes the screen uniformly causing the

“fullscreen” effect.

Attach the event at page load of the silverlight page :

this.showcaseMediaPlayer.FullScreenEventHandler += new RoutedEventHandler(this.FullscreenChange);

The event is triggered at the click of the full screen button the media control.

Essentially the event set the video brush media (“media”) attributes.

Event Trigger:

/// <summary>

/// Event handling the fullscreen change event.

/// </summary>

/// <param name="sender">Sender of the event.</param>

/// <param name="e">Event arguments.</param>>

private void FullscreenChange(object sender, EventArgs e)

{

Application.Current.Host.Content.IsFullScreen = true;

this.videoPosition = this.mediaPlayer.VideoPosition;

this.volume = this.mediaPlayer.Volume;

this.playerCurrentState = this.showcaseMediaPlayer.PlayerCurrentState;

}

The media is set as the media player state so that the fullscreen seems seamless.



On “Escape” of the full screen, the videobrush get back to normal form and the media player continues playing.



Author: NekkantiDivya    12 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi Lalji,

Thanks for your reply.

I tried your solution but have some doubts in it.

1. what is showcaseMediaPlayer? Is it a media element or media player?
2. Are showcaseMediaPlayer and media are two different controls?
3. I am not getting videoPosition or palyercurrentstate etc methods. What are they?
4. In my application I have a group of videos(nearly 6). All these are a single user control(video.xaml) which is user repeatedly and this adding usercontols is done in MainPage.xaml, then this is used in Home.aspx page. Now when we click on the button in the usercontrol it should be fullscreened.

If you have any idea to solve them or need any clarification please reply me.


Thanks in advance.



Post Reply
You must Sign In to post a response.
Next : Animation in silverlight
Previous : Assign to dataset in silvertlight datagrid
Return to Discussion Forum
Post New Message
Category: Silverlight

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use