This is a migrated thread and some comments may be shown as answers.

A simple understanding!

4 Answers 94 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Fairoz
Top achievements
Rank 1
Fairoz asked on 25 Aug 2011, 01:26 AM

Hi, I am new to this Silverlight thing and had many years experience in developing desktop application.
I am having some trouble with the RadMediaPlayer. I took a sample project from a post in the forum here and could not play the file.

Below is the XAML code in the control

<telerik:RadMediaPlayer x:Name="player" VerticalContentAlignment="Top"
        HorizontalContentAlignment="Center"
        Header="Sample Video">
    <telerik:RadMediaItem Title="Bear" Name="radMediaItem" Source="Bear.wmv">
    </telerik:RadMediaItem>
</telerik:RadMediaPlayer>

I made many copies of the file "Bear.wmv" and resides in the following locations of the web project. (Attached image)
1. In the App_Code
2. In the App_Data
3. Bin
4. Client Bin
5. Under the project

And I have tried
<telerik:RadMediaItem Title="Bear" Name="radMediaItem" Source="http://localhost/MyWebSiteSite/ClientBin/Bear.wmv"/>
and
<telerik:RadMediaItem Title="Bear" Name="radMediaItem" Source="/ClientBin/Bear.wmv"/>
and
<telerik:RadMediaItem Title="Bear" Name="radMediaItem" Source="~/ClientBin/Bear.wmv"/>
and
<telerik:RadMediaItem Title="Bear" Name="radMediaItem" Source="../../ClientBin/Bear.wmv">
and many others of such combinations

and I always get "Failed to load media".... the media file "Bear.wmv" was from a project uploaded by Admin at the forum below (gives me error because of its old VS version). I am using VS2010 pro + Expression Ultimate

http://www.telerik.com/community/forums/silverlight/media-player/wmv-won-t-play.aspx

Why is that and am I missing something?

Thanks.

4 Answers, 1 is accepted

Sort by
0
Fairoz
Top achievements
Rank 1
answered on 25 Aug 2011, 01:49 AM

Ok....... I found something out just now.

The below works
If the file is in the ClientBin..... then the code in XAML is
<telerik:RadMediaPlayer x:Name="player"  Header="Sample Video">
           <telerik:RadMediaItem Title="Bear.wmv" Name="radMediaItem" Source="/Bear.wmv"/>
</telerik:RadMediaPlayer>
[note the slash in "/Bear.wmv"]

But how can I play the content from App_Data or App_Code virtual directories??

Thanks
0
Tina Stancheva
Telerik team
answered on 30 Aug 2011, 12:19 PM
Hi Fairoz,

The RadMediItem in its core is a wrapper around the MediaElement control and as such has no access to the local file system. So in order to be able to play video files with Silverlight, you'll need to make them visible to the world (through http or Media Services...) and after that play them in the RadMediaPlayer as RadMediaItems with source like "http://mydomain.com/Videos/Bear.wmv". Or you will have to place them in the folder containing your .xap, so that they can be requested under the same path (Source="/Bear.wmv" - this relative path indicates the folder where the SL xap is located, in this case the ClientBin and this is why placing the movie in the ClientBin works).

However as a security measure, files in the App_Data, App_Code folders are not served by the Web server. This is why if you place your move in any of those folders it won't be public and you won't be able play it in the MediaElement of the RadMediaPlayer.

I hope this information will help you.


Greetings,
Tina Stancheva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Chandana
Top achievements
Rank 1
answered on 20 Dec 2011, 08:00 PM
Hi,

Just like you mentioned, I am using the relative path after placing the mp4 file in the ClientBin folder. I want to play a smooth streaming video at the same time.

The below code wouldn't work because of the relative source. It is throwing a "Failed to open media" error. Can you please help me with the relative source path and the manifesturl?

 <telerik:RadMediaPlayer CanSeek="True" Height="334" HorizontalAlignment="Left" Name="player" VerticalAlignment="Top" Width="540" MediaEnded="player_MediaEnded">
            <telerik:RadMediaItem IsStreamingSource="True" VideoStretch="Fill" Source="/TestVideo.mp4" StreamAttached="RadMediaItem_StreamAttached">
                </telerik:RadMediaItem>
        </telerik:RadMediaPlayer>

private void RadMediaItem_StreamAttached(object sender, EventArgs e)
{
    var item = sender as RadMediaItem;
    if (item != null)
    {
        var adaptiveSource = new AdaptiveStreamingSource();
        adaptiveSource.MediaElement = player.MediaElement;
        adaptiveSource.ManifestUrl = item.Source;
        adaptiveSource.StartPlayback();
    }
}
Regards,
Chandana
0
Tina Stancheva
Telerik team
answered on 23 Dec 2011, 04:22 PM
Hello Chandana,

If you want to take advantage of the smooth streaming support of the RadMediaPlayer, you need to set the RadMediaItem Source to a Smooth Streaming content. This means that you'll have to encode your mp4 video for example using the Expression Encoder 3. You can find more information here.

Please keep in mind that at the moment the RadMediaPlayer doesn't support smooth streaming of a content encoded with Expression Encoder 4.

I hope this information will help you. Please let us know if we can further assist you.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
MediaPlayer
Asked by
Fairoz
Top achievements
Rank 1
Answers by
Fairoz
Top achievements
Rank 1
Tina Stancheva
Telerik team
Chandana
Top achievements
Rank 1
Share this question
or