NovCTP - MediaPlayerSample

Hi,

Anyone have a sample on how to draw video in NovCTP.
I have the following at the momment but fails to play video just audio.

MediaPlayer player;

public Window1(){

   InitializeComponent();
   player =
new MediaPlayer();
   MediaTimeline t = new MediaTimeline();
   t.Source =
new Uri(@"Japan.wmv");
   MediaClock c = t.CreateClock();
   player.Clock = c;
}

protected override void OnRender(DrawingContext drawingContext){

   drawingContext.DrawVideo(player,new Rect(RenderSize));
   base.OnRender(drawingContext);
}

kind regards,




Answer this question

NovCTP - MediaPlayerSample

  • maheshbabui

    Are you trying to do something fancy with multiple renderings or just want to get video to play   The MediaElement handles rendering more directly than overriding OnRender.  In Nov CTP there is a new per-frame notification you could use to trigger a refresh and use something like a DrawingVisual or one of the others.  You really want to get away from immediate mode rendering with WPF.  As much as possible set up the elements you want rendered and let the system do it.  Even for fancy synchronized rendering the new notification allows you to alter the drawing on a per-frame basis without resorting to imediate mode drawing.

  • M-Studios

    Thanks for the advice. The domain is rather more complicated but your advice is noted; I will start to move that way. The real problem for me i think was the change in the mechanics of the media element. i used to be able to stream from a custom httplistener to the DrawingContext, now media player or element does not play the stream however WMP does [tears!] :D

  • zkent

    The streaming case is a bug with the November CTP, and should be fixed in subsequent releases.
  • Ralphxyz

    Andy_Webber_ wrote:
    Hmm, im doing on override OnRender here but i guess i can try again.

    as for the streaming it probably me but
    <MediaElement Source="C:\Inetpub\wwwroot\ImagineBlogger\2.asf"/> Works
    <MediaElement Source="http://awebbermedia/imagineblogger/2.asf"/> Doesnt

    Has anyone figured this out, I cannot get it work either. Thanks, Dvl


  • AvinashA

    The reason nothing is being drawing is likely because Window has a default style with some child drawing a white background over the whole Window.  You can use DrawVideo into a DrawingVisual, or create a customized control/UIElement and override its OnRender method with the one you have above.

    As for streaming from an http URL, it is expected to work.  If not, it is likely not related to the code sample you have above.

  • Sergio G

    Hmm, im doing on override OnRender here but i guess i can try again.

    as for the streaming it probably me but
    <MediaElement Source="C:\Inetpub\wwwroot\ImagineBlogger\2.asf"/> Works
    <MediaElement Source="http://awebbermedia/imagineblogger/2.asf"/> Doesnt

  • ericsstoll

    Thank the lord!, i thought i was insane.

    my boss wont fire me now, thanks



  • NovCTP - MediaPlayerSample