Platforms to show: All Mac Windows Linux Cross-Platform

Back to DirectShowMediaControlMBS class.

DirectShowMediaControlMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The private constructor.

DirectShowMediaControlMBS.GetState(msTimeout as Integer = -1) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Retrieves the state of the filter graph—paused, running, or stopped.

msTimeout: Duration of the time-out, in milliseconds, or INFINITE (-1) to specify an infinite time-out.

State transitions are not necessarily synchronous. Therefore, when you call this method, the filter graph might be in transition to a new state. In that case, the method blocks until the transition completes or until the specified time-out elapses.

Lasterror is set.

Applications can use this method to determine whether playback has started after a call to Run. Generally, applications should have their own mechanism for tracking which state they have put the filter graph into. Applications typically use the current state to determine which user interface controls are enabled or disabled. For example, once the graph goes into the running state, the application might disable a "Play" button and enable "Stop" and "Pause" buttons.
If the filter graph is in a transition to a new state, the returned state is the new state, not the previous state.
This method returns an error if there is a call on another thread to change the state while this method is blocked.
Avoid specifying a time-out of INFINITE, because threads cannot process messages while waiting in GetState. If you call GetState from the thread that processes Windows messages, specify small wait times on the call in order to remain responsive to user input. This is especially important when the source is streaming over a network or from the Internet because state transitions in these environments can take significantly more time to complete.

DirectShowMediaControlMBS.Pause

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Pauses all the filters in the filter graph.

Lasterror is set.

Pausing the filter graph cues the graph for immediate rendering when the graph is next run. While the graph is paused, filters process data but do not render it. Data is pushed through the graph and processed by transform filters as far as buffering permits, but renderer filters do not render the data. However, video renderers display a static poster frame of the first sample.

If the method returns S_FALSE, call the GetState method to wait for the state transition to complete, or to check if the transition has completed. When you call Pause to display the first frame of a video file, always follow it immediately with a call to GetState to ensure that the state transition has completed. Failure to do this can result in the video rectangle being painted black.
If the method fails, it stops the graph before returning.

DirectShowMediaControlMBS.RenderFile(FilePath as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Builds a filter graph that renders the specified file.

Lasterror is set.

filePath: Specifies the name of the file to load.

DirectShowMediaControlMBS.Run

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Runs all the filters in the filter graph.

While the graph is running, data moves through the graph and is rendered.
Lasterror is set.

If the filter graph is stopped, this method pauses the graph before running. If the graph is already running, the method returns S_OK but has no effect.
The graph runs until the application calls the Pause or Stop method. When playback reaches the end of the stream, the graph continues to run, but the filters do not stream any more data. At that point, the application can pause or stop the graph. For information about the end-of-stream event, see Pause and EC_COMPLETE.
This method does not seek to the beginning of the stream. Therefore, if you run the graph, pause it, and then run it again, playback resumes from the paused position. If you run the graph after it has reached the end of the stream, nothing is rendered. To seek the graph, use the MediaSeeking interface.
If method returns S_FALSE, it means that the method returned before all of the filters switched to a running state. The filters will complete the transition after the method returns. Optionally, you can wait for the transition to complete by calling the GetState method with a timeout value. However, this is not required.
If the Run method returns an error code, it means that one or more filters failed to run. However, some filters might be in a running state. In a multistream graph, entire streams might be playing successfully. Typically the application would tear down the graph and report an error in this case.

DirectShowMediaControlMBS.Stop

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Stops all the filters in the graph.

Lasterror is set.

If the graph is running, this method pauses the graph before stopping it. While paused, video renderers can copy the current frame to display as a poster frame.

This method does not seek to the beginning of the stream. If you call this method and then call the Run method, playback resumes from the stopped position. To seek, use the IMediaSeeking interface.

The Filter Graph Manager pauses all the filters in the graph, and then calls the Stop method on all filters, without waiting for the pause operations to complete. Therefore, some filters might have their Stop method called before they complete their pause operation. If you develop a custom rendering filter, you might need to handle this case by pausing the filter if it receives a stop command while in a running state. However, most filters do not need to take any special action in this regard.

DirectShowMediaControlMBS.StopWhenReady

Type Topic Plugin Version macOS Windows Linux iOS Targets
method DirectShow MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Pauses the filter graph, allowing filters to queue data, and then stops the filter graph.

Lasterror is set.

This method is useful if you want to seek the filter graph while the graph is stopped. As long as the filter graph is stopped, changes in the current position do not repaint the video window with a new frame. Therefore, calling SetPositions does not update the video window. To update the window after the seek operation, call StopWhenReady. This method transitions the graph to a paused state, waits for the pause operation to complete, and then transitions the graph back to stopped. The pause operation queues data in the graph, so that the video renderer receives and displays the new frame.

This method is asynchronous. It waits on a separate thread for the pause to complete. The calling thread does not block, which enables the application to respond to user input. When the method returns, the logical state of the graph is stopped, even before the pause operation completes. If you call the GetState method at this point, it returns State_Stopped.

If the application issues another state-change command (such as pause, run, or seek) before the pause operation completes, the new command cancels the pending stop command. The pause operation completes, but the graph does not stop.

Some examples using this method:

The items on this page are in the following plugins: MBS Win Plugin.


The biggest plugin in space...