21 Answers, 1 is accepted
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.
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.
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
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.
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
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.
Thx
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.
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..
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.
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.
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
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.
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
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
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
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
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