/// <summary> /// Captures a video frame, asynchronously. /// </summary> /// <returns>A task that represents the asynchronous capture operation.</returns> /// <feature>http://tizen.org/feature/multimedia.raw_video</feature> /// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks> /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception> /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception> /// <exception cref="NotSupportedException">The required feature is not supported.</exception> /// <since_tizen> 3 </since_tizen> public async Task <CapturedFrame> CaptureVideoAsync() { ValidationUtil.ValidateFeatureSupported(PlayerFeatures.RawVideo); ValidatePlayerState(PlayerState.Playing, PlayerState.Paused); TaskCompletionSource <CapturedFrame> t = new TaskCompletionSource <CapturedFrame>(); NativePlayer.VideoCaptureCallback cb = (data, width, height, size, _) => { Debug.Assert(size <= int.MaxValue); byte[] buf = new byte[size]; Marshal.Copy(data, buf, 0, (int)size); t.TrySetResult(new CapturedFrame(buf, width, height)); }; using (var cbKeeper = ObjectKeeper.Get(cb)) { NativePlayer.CaptureVideo(Handle, cb) .ThrowIfFailed(this, "Failed to capture the video"); return(await t.Task); } }