MultiSourceMediaFrameReader.FrameArrived Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when a new frame arrives from all of the media frame sources associated with the MultiSourceMediaFrameReader.
// Register
event_token FrameArrived(TypedEventHandler<MultiSourceMediaFrameReader, MultiSourceMediaFrameArrivedEventArgs const&> const& handler) const;
// Revoke with event_token
void FrameArrived(event_token const* cookie) const;
// Revoke with event_revoker
MultiSourceMediaFrameReader::FrameArrived_revoker FrameArrived(auto_revoke_t, TypedEventHandler<MultiSourceMediaFrameReader, MultiSourceMediaFrameArrivedEventArgs const&> const& handler) const;
public event TypedEventHandler<MultiSourceMediaFrameReader,MultiSourceMediaFrameArrivedEventArgs> FrameArrived;
function onFrameArrived(eventArgs) { /* Your code */ }
multiSourceMediaFrameReader.addEventListener("framearrived", onFrameArrived);
multiSourceMediaFrameReader.removeEventListener("framearrived", onFrameArrived);
- or -
multiSourceMediaFrameReader.onframearrived = onFrameArrived;
Public Custom Event FrameArrived As TypedEventHandler(Of MultiSourceMediaFrameReader, MultiSourceMediaFrameArrivedEventArgs)
Event Type
Remarks
In the handler for the FrameArrived event, call TryAcquireLatestFrame on the MultiSourceMediaFrameReference passed in as the sender parameter to the event handler to get a MultiSourceMediaFrameReference representing the latest set of correlated frames from the media frame sources for which the reader was created. Then, get the time-correlated media frame from a particular media frame source by calling TryGetFrameReferenceBySourceId and passing in the value of the MediaFrameSourceInfo.Id property for the desired media frame source.
Note that this event is only raised when a new frame is available from all of the media frame sources associated with the MultiSourceMediaFrameReader. For example, if one of the sources produces frames at twice the rate of another, half of the frames from the faster source will be dropped and this event will only be raised when the slower frame source has a new frame available. For this reason, it's a good idea to set up an event and signal it each time this event is raised. In a separate thread, you can check to see if the event has been signaled within a specified time window, 5 seconds for example. If the event has not been signaled with the time window, your app can deduce that one of the frame sources is no longer generating frames and that the reader should be stopped.
For how-to guidance on working with time-correlated media frames, see Process media frames with MediaFrameReader.