none
WPF media player problem - seek to function is skipping RRS feed

  • Question

  • Hello

    Im creating a simple mp3 media player  (C# WPF Application) and i created a function to jump to different parts of the media ( seek to ) with this code:

    private
    
     void
    
     SeekToMediaPosition(object sender, RoutedPropertyChangedEventArgs<double> args)
    {
    int SliderValue = (int )timelineSlider.Value;
    TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue);
    myMediaElement.Position = ts;
    }

    Here is the problem : When i play a file (.mp3 /.wma)  and i want to jump to the middle of the song (by moveing the slider) the song starts skipping to the the time positioned on by the slider and then plays normal again.
    • Edited by fivepoints Wednesday, February 24, 2010 10:35 PM
    • Moved by Rudedog2 Thursday, February 25, 2010 1:56 PM WPF issue (From:Visual C# General)
    Wednesday, February 24, 2010 8:17 PM

Answers

  • Hi FivePoints,


    i think i know what you mean, because i had a similar problem.


    I have a slider that i use to position video.  and if i connect the slider directly up to the video position, firstly the performance of the slider is very bad( it responds slowly )  and the video doesnt move smoothly.


    I ended up unbinding the slider control from position and responding to the "mouse button up" event on the slider.  when the user lets go of the mouse button, then i set the position in mediaelement.



    i guess its a simple work around.


    Cheers
    Anton



    Friday, February 26, 2010 11:35 PM

All replies

  • Does this happen only while you are moving the timelineSlider control....with the mouse I assume?

    Mark the best replies as answers. "Fooling computers since 1971."
    Wednesday, February 24, 2010 9:05 PM
  • I would recommend that you use SkyDrive to post a sample of your code.

    You should also state the problem more clearly, and at least answer questions asked of you.
    I would say it is a fair trade.  We will try to answer yours, if you will try to answer ours.

    For questions related to Windows Presentation Foundation, please use the  Windows Presentation Foundation (WPF) forum.
    Mark the best replies as answers. "Fooling computers since 1971."
    Thursday, February 25, 2010 1:55 PM
  • I know what you mean that the sound si skipping while Im moving the timeslider control. This is not the problem.

    The problem is : I select for example a song I click play, the song starts playing... then i click the slidercontrol and drag it to the middle ( when Im doing this the song stops playing - not as you meanchend that is skipps ) and when I let go the click button on the mouse on the middle of the slidercontrol it starts skipping for a while and then the song plays from the middle.

    I made a quick sample, so you can run it and see whats the problem.

    http://cid-1429394c24f1b0bd.skydrive.live.com/self.aspx/.Public/Wpf%20Player.zip


    Im from Europe so sorry for my english im trying
    Please help





    Friday, February 26, 2010 2:38 PM
  • Hi FivePoints,


    i think i know what you mean, because i had a similar problem.


    I have a slider that i use to position video.  and if i connect the slider directly up to the video position, firstly the performance of the slider is very bad( it responds slowly )  and the video doesnt move smoothly.


    I ended up unbinding the slider control from position and responding to the "mouse button up" event on the slider.  when the user lets go of the mouse button, then i set the position in mediaelement.



    i guess its a simple work around.


    Cheers
    Anton



    Friday, February 26, 2010 11:35 PM
  • Followup on this problem

     

    looks like there may be a better solution

     

    http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/31ceb397-225a-44a7-aaa2-ee28a59c1e0c

     

     

    cheers

    Anton

    Saturday, March 20, 2010 2:40 AM
  • I will , thenks
    Sunday, March 21, 2010 4:39 PM