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

Create RadMediaItem from file

21 Answers 296 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Helen
Top achievements
Rank 2
Helen asked on 28 Apr 2009, 02:23 AM
Is there any way to create a RadMediaItem to play by choosing a file from the local file system?

thx

Helen

21 Answers, 1 is accepted

Sort by
0
Helen
Top achievements
Rank 2
answered on 28 Apr 2009, 03:34 AM
Never mind, I found a work-around by setting the Player's MediaElement's source to a file stream, and then playing it.
0
Dan M
Top achievements
Rank 1
answered on 03 Nov 2009, 11:21 PM
Has anyone found a solution for the initial question?
0
Kiril Stanoev
Telerik team
answered on 04 Nov 2009, 11:06 AM
Hello Dan,

Currently this scenario is not supported by RadMediaPlayer. Future versions of RadMediaPlayer will definitely support this functionality, but for the moment, the only way to play a local file is to pass its stream to RadMediaPlayer's MediaElement.

private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
    OpenFileDialog openFileDialog1 = new OpenFileDialog();
 
    if (openFileDialog1.ShowDialog() == true)
    {
        Stream fileStream = openFileDialog1.File.OpenRead();
        mediaPlayer.MediaElement.SetSource(fileStream);
    }
}

I am attaching my sample project for further reference.

Kind regards,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
savitha d
Top achievements
Rank 1
answered on 01 Dec 2009, 07:05 AM
Can i take the Souce from direct  local path i dont need openfiledialog is it possible?
0
Kiril Stanoev
Telerik team
answered on 02 Dec 2009, 05:15 PM
Hi Savitha,

In Silverlight, the only way to gain access to the local file system is through the OpenFileDialog / SaveFileDialog classes.

Regards,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Helen
Top achievements
Rank 2
answered on 14 Apr 2010, 09:15 PM

When I run the code using the latest version and I use the "Browse" button to set the MediaElement, it throws the following exception:

 

{System.Windows.ApplicationUnhandledExceptionEventArgs}
    base {System.EventArgs}: {System.Windows.ApplicationUnhandledExceptionEventArgs}
    ExceptionObject: {System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.ItemsControlExtensions.<GetContainers>d__0`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
   at Telerik.Windows.Controls.RadMediaPlayer.SetTickMarksOnTimeSlider()
   at Telerik.Windows.Controls.RadMediaPlayer.MediaElement_MediaOpened(Object sender, RoutedEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)}
    Handled: false

0
Miro Miroslavov
Telerik team
answered on 16 Apr 2010, 02:05 PM
Hello Helen,

Thank you for reporting this issue. We'll fix it as soon as possible.
Till then you can workaround it with setting the mediaPlayer.SelectedIndex = 0.
<telerikMediaPlayer:RadMediaPlayer x:Name="mediaPlayer" Width="800" Height="600"
                    SelectedIndex="0">

Hope this works for you.

Sincerely yours,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Helen
Top achievements
Rank 2
answered on 16 Apr 2010, 07:43 PM
Hi guys,

Your fix works in a simple project, but when I try to use the RadMediaPlayer in a bigger project, I get the same error, even when I add the SelectedIndex="0" to the Xaml for the RadMediaPlayer.

So please let me know when you have a fix.

Best

Helen
0
Miro Miroslavov
Telerik team
answered on 21 Apr 2010, 01:49 PM
Hello Helen,

It's logged and should be fixed. Till then, we can provide you help support if needed. You can send us example project where you get error, so we can think of workaround.

All the best,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Helen
Top achievements
Rank 2
answered on 21 May 2010, 01:30 AM
So -- any idea when the fix will be in? I'm anxious to convert to your media player from the one I am currently using.

Thx

Helen
0
Miro Miroslavov
Telerik team
answered on 27 May 2010, 06:05 AM
Hi Helen,

At the moment we can't promise you exact date.
Sorry for the inconvenience.

Greetings,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Manuel Felício
Top achievements
Rank 1
answered on 28 Jun 2010, 08:03 PM
We are trying to use RadMediaPlayer and we're getting the same issue. It seems at the moment RadMediaPlayer is pretty useless unless you can fix the ALWAYS throwing NullReferenceException when we set an the MediaElement source.

Another strange thing is that the MediaElement property is null after the RadMediaPlayer loaded event is fired, but if I have a button somewhere and click it then the MediaElement property has a value, so there must be some backround running task that must complete before the MediaElement gets set, but I don't know when it completes..

In my case I have an in-memory byte[] stream that I want to play. I open a RadWindow, find a view that can play a specified type of file, in this case it would be the RadMediaPlayer, put it in the Window and set the MediaElements' Source to my stream..fails (NullReferenceException).

Any clues?

Edit: don't get me wrong.. I might have sounded a little bit rude here but the fact is that RadMediaPlayer does a lot of complex stuff in a wonderful way but it fails to do the basic stuff, which is very frustrating..
0
Manuel Felício
Top achievements
Rank 1
answered on 29 Jun 2010, 10:18 AM
Well, here goes my current work-around:

void MainPage_Loaded(object sender, RoutedEventArgs e)  
        {  
            Dispatcher.BeginInvoke(() => 
            {  

                   player.Items.Clear();

                var stream = typeof(MainPage).Assembly.GetManifestResourceStream("SilverlightApplication1.Assets.Wildlife.wmv");  
                player.MediaElement.SetSource(stream);  
            });  
        } 

Notice that in the loaded event the MediaElement is null, but when the delegate I pass to the BeginInvoke method gets called the MediaElement is not null anymore.. I'm not sure if this happens all the time, but for now it works.

In the Xaml I have the media player with a sample video and SelectedIndex=0.

Best regards,

Manuel Felício.
0
Manuel Felício
Top achievements
Rank 1
answered on 29 Jun 2010, 03:23 PM
Digging deeper, I've created an HttpHandler and I'm streaming the binary file to the HttpResponse OutputStream. This way allows me to use RadMediaItem's with Uri sources.

Everything is working great, I'm surprised it works for different types of files without me having to specify the content-type of the HttpResponse.

The only problem is that since this isn't a real streaming service I don't support seeking, but I haven't found a way in RadMediaPlayer to disable seeking to a position that hasn't been downloaded yet. For example, I should be able to seek to a position that I've already downloaded but not to a position that hasn't been downloaded yet. Does this make sense?

Best regards,

Manuel Felício.
0
Miro Miroslavov
Telerik team
answered on 30 Jun 2010, 01:15 PM
Hello Manuel Felício,

I get your idea, but RadMediaPlayer doesn't support this scenario. I think that for best user experience, you should use the regular streaming services provided by IIS or some other streaming services.
If we can be of further help please ask us.

Greetings,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Manuel Felício
Top achievements
Rank 1
answered on 30 Jun 2010, 03:40 PM
Thanks for your response.

Yes you can! :)

When RadMediaPlayer tries to seek to a position how does that position gets passed in the http request? Is there a way for me to access the seek position in my HttpHandler?

Best regards,

MF.
0
Miro Miroslavov
Telerik team
answered on 02 Jul 2010, 02:04 PM
Hello Manuel Felício,

RadMediaPlayer is just a wrapper around the Silverlight build in MediaElement. Which handles internally about everything related to reading the streams, seeking, playing, pausing and etc. And the worst thing is that most of the logic is in native methods.
This is why we don't have the control over the seeking and i don't think you have a way to access and modify the seek position http requests.

Regards,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Malcolm
Top achievements
Rank 1
answered on 06 Jan 2011, 10:02 AM
Hi Miro Miroslavov,the Telerik team 

Is there away in which we could pick MediaItems for the RadMediaPlayer directly from the local hard disk? am doing a Touchscreen & idont think it will be agood idea to ask users to pick .WMV files by use of OpenDialog. It will simply bit the logic. or is there a simpler workaround for the same?

George Moyi
developer
0
Tina Stancheva
Telerik team
answered on 11 Jan 2011, 02:15 PM
Hi Helen,

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 (thought http or Media Services...) and after that play them in the RadMediaPlayer as RadMediaItems with source like "http://mydomain.com/Videos/sample.wmv". Or you will have to place them in the folder containing your .xap, so that they can be requested under the same path.

All the best,
Tina Stancheva
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Greg Sipes
Top achievements
Rank 1
answered on 14 Mar 2011, 09:00 PM
Miro,
    Has Helen's issue been fixed yet? I am having the same problem. I also attempted to add the SelectedIndex = 0, but no luck. I saw in another forum, that I should check the mediaFailed event of the mediaElement, but that doesn't get hit before the debugging error is thrown.Any ideas?

I see Tina's most recent post, but if thats the case, the documenation should not say that it can render a stream, when in fact it needs a file path.

Thanks in advance,
Greg
0
Tina Stancheva
Telerik team
answered on 17 Mar 2011, 05:18 PM
Hi Greg Sipes,

Unfortunately the issue is still not fixed due to the many pressing tasks in our to-do list. Therefore at the moment you can only play public streams/videos (thought http or Media Services...)

However, we will do our best to fix this issue as soon as possible. You can track its progress here.

Please accept our apology for the caused inconvenience.

Regards,
Tina Stancheva
the Telerik team
Tags
MediaPlayer
Asked by
Helen
Top achievements
Rank 2
Answers by
Helen
Top achievements
Rank 2
Dan M
Top achievements
Rank 1
Kiril Stanoev
Telerik team
savitha d
Top achievements
Rank 1
Miro Miroslavov
Telerik team
Manuel Felício
Top achievements
Rank 1
Malcolm
Top achievements
Rank 1
Tina Stancheva
Telerik team
Greg Sipes
Top achievements
Rank 1
Share this question
or