mediaelement

Show first frame of video in WPF MediaElement

你离开我真会死。 提交于 2019-11-27 19:12:01
问题 I have a WPF-application with a MediaElement which I use to run a video. I don't want the video to autoplay when loaded, so I set the LoadedBehavior to Manual. <MediaElement LoadedBehavior="Manual" Source="foo.wmv" MediaOpened="videoElement_MediaOpened" /> However; I want the element to show the first frame of the video when loaded. Is there any magic way of doing this? 回答1: You also need ScrubbingEnabled="True" Then set an event on Load Loaded="Video1_Loaded" In the Video1_Load method add

Why does WPF MediaElement not work on secondary monitor?

十年热恋 提交于 2019-11-27 14:37:25
问题 My application uses the WPF MediaElement to play video (MOV files). This works well when playing on the Primary monitor but freezes when the window is moved to the secondary monitor. I have tried the following without success: Starting the application on the secondary monitor Swapping the primary & secondary monitors (problem transfers to the new secondary monitor) When the application window spans both monitors it works correctly but as soon as it is entirely within the secondary monitor the

MVVM pattern violation: MediaElement.Play()

若如初见. 提交于 2019-11-27 12:27:25
I understand that ViewModel shouldn't have any knowledge of View, but how can I call MediaElement.Play() method from ViewModel, other than having a reference to View (or directly to MediaElement) in ViewModel? Other (linked) question: how can I manage View's controls visibility from ViewModel without violating MVVM pattern? ken2k 1) Do not call Play() from the view model. Raise an event in the view model instead (for instance PlayRequested ) and listen to this event in the view: view model: public event EventHandler PlayRequested; ... if (this.PlayRequested != null) { this.PlayRequested(this,

Using MediaElement to play video from Stream

夙愿已清 提交于 2019-11-26 18:52:26
Is it possible to use the WPF MediaElement to play streaming video from a System.IO.Stream object? The Stream object is being retrieved from a WCF service that stores the media files. IF you can make the WCF deliver the Media Object via a http-URL (GET) then you can just assign that URL to the MediaElement.Source property - see http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source.aspx . For cases where such URL is not available/possible: Assigning a Stream is currently not possible - although there are some hacks to make that happen, for a DirectShow-based

MVVM pattern violation: MediaElement.Play()

和自甴很熟 提交于 2019-11-26 16:00:26
问题 I understand that ViewModel shouldn't have any knowledge of View, but how can I call MediaElement.Play() method from ViewModel, other than having a reference to View (or directly to MediaElement) in ViewModel? Other (linked) question: how can I manage View's controls visibility from ViewModel without violating MVVM pattern? 回答1: 1) Do not call Play() from the view model. Raise an event in the view model instead (for instance PlayRequested ) and listen to this event in the view: view model:

Using MediaElement to play video from Stream

眉间皱痕 提交于 2019-11-26 06:38:32
问题 Is it possible to use the WPF MediaElement to play streaming video from a System.IO.Stream object? The Stream object is being retrieved from a WCF service that stores the media files. 回答1: IF you can make the WCF deliver the Media Object via a http-URL (GET) then you can just assign that URL to the MediaElement.Source property - see http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source.aspx. For cases where such URL is not available/possible: Assigning a Stream