How to move the video forward/backward when user drags the slider bar.?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How to move the video forward/backward when user drags the slider bar.?

  1. #1
    Join Date
    Nov 2009
    Posts
    24

    Question How to move the video forward/backward when user drags the slider bar.?

    Hi,

    I am working on a project in which I use DirectShow to Play / Pause / Stop the video. I am using slider bar to show the progress of the video. As the video starts playing, the slider bar moves in proportion to the video duration. Now when user moves/drags the slider bar to a new position, I want to forward the video in equivalent proportion.

    Say if video duration is 50 seconds and max range of the slider bar is set to 100. slider will 2 steps for 1 second of video progress. Now if user drags the slider to 60 while video is playing, I want to increment/forward the video.
    if user moves the slider backward, video should move backward.

    I have done with the slider moving along with the video and when user drags the slider.
    please let me know how to set the new position of the video, so that the video starts playing from that point.

    Anybody have any idea or any sample code for the same.?

    Thanks in advance.

    Regards,
    Mbatra

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,877

    Re: How to move the video forward/backward when user drags the slider bar.?

    You stop your graph right at the moment when user pressed left button down. And detect the mouse position, and calculate presentation time for that, and extract video frame for the position, and show it. And you do that for any further mouse move until the button releases. Then you start your graph from the last known position.

    Or you just use IMediaSeeking interface
    The IMediaSeeking interface contains methods for seeking to a position within a stream, and for setting the playback rate. The Filter Graph Manager exposes this interface, and so do individual filters or pins. Applications should query the Filter Graph Manager for the interface.
    Best regards,
    Igor

  3. #3
    Join Date
    Nov 2009
    Posts
    24

    Re: How to move the video forward/backward when user drags the slider bar.?

    Quote Originally Posted by Igor Vartanov View Post
    You stop your graph right at the moment when user pressed left button down. And detect the mouse position, and calculate presentation time for that, and extract video frame for the position, and show it. And you do that for any further mouse move until the button releases. Then you start your graph from the last known position.

    Or you just use IMediaSeeking interface

    Hi Igor,

    Thanks for the info.
    Can u share me some sample code using IMediaSeeking. I have one issue, I am using a callback function in which I am getting IMediaControl pointer from another file which is actually running the video file. When I am getting the IMediaSeeking Interface pointer, it might be getting NULL, because my application crashes there....After getting IMediaSeeking interface pointer, I am using Setposition with the new position for the file to play from.


    is there any way that I can get IMediaSeeking interface pointer from IMediaControl pointer.?

    Regards,
    Mbatra

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,877

    Re: How to move the video forward/backward when user drags the slider bar.?

    Never was in a situation like yours, as I always had all interfaces under control. You may try to acquire IGraphBuilder interface from IMediaControl, and then ask the graph for IMediaSeeking.
    Best regards,
    Igor

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,641

    Re: How to move the video forward/backward when user drags the slider bar.?

    note that not all video formats or codecs allow for setting a playback position, or don't allow you to set it anywhere you want (some have say a 5sec granularity, so you can set playback to 10 or 15sec but not somethign in between).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center