none
thumb video with mediaplayer how to avoid black thumb RRS feed

  • Question

  • i need to get the thumb of a video file, when i use the videoplayer sometime the thumb is fully black

     

    is there a way to avoid this sort of problem?

    Friday, April 16, 2010 10:23 AM

Answers

  • Hi Marck68,

    You can set a position for the MediaPlayer and add a event to MediaOpened. Invoke the Play method firstly and Stop in the MediaOpened event. Now you will get the thumb of the position we set.

    Something likes the follows:
    XAML
    <Grid>
        <Rectangle Stroke="Black" StrokeThickness="1" Name="myrect">
        </Rectangle>
    </Grid>

    Code-behind
    MediaPlayer player = new MediaPlayer();

    MediaPlayer player = new MediaPlayer();

    public MediaPlayerDemo()

    {

        InitializeComponent();

     

        player.Open(new Uri(@"hg.wmv", UriKind.Relative));

        VideoDrawing aVideoDrawing = new VideoDrawing();

        DrawingBrush myDrawingBrush = new DrawingBrush();

        aVideoDrawing.Rect = new Rect(0, 0, 100, 100);

        aVideoDrawing.Player = player;

        player.MediaOpened += new EventHandler(player_MediaOpened);

        player.Play();

        player.Position = TimeSpan.FromSeconds(30);

       

        myDrawingBrush.Drawing = aVideoDrawing;

        myrect.Fill = myDrawingBrush;

     

    }

     

    void player_MediaOpened(object sender, EventArgs e)

    {

        player.Stop();
    }

    Hope this helps.

    Best regards,
    Linda Liu


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Linda Liu Friday, April 23, 2010 3:18 AM
    Wednesday, April 21, 2010 2:28 AM