void _device_VideoFragmentReady(NikonDevice sender, NikonVideoFragment fragment) { // Open the filestream when we receive the first video fragment if (fragment.IsFirst) { _fileStream = new FileStream(fragment.Filename, FileMode.Create, FileAccess.Write); } // Save video fragments to file _fileStream.Write(fragment.Buffer, 0, fragment.Buffer.Length); // When we recive the last fragment, close the file and signal that we're done if (fragment.IsLast) { _fileStream.Close(); _waitForVideoCompleted.Set(); } }
void device_VideoFragmentReady(NikonDevice sender, NikonVideoFragment fragment) { string path = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), fragment.Filename); if (fragment.IsFirst) { Debug.Assert(_videoFile == null); _videoFile = new FileStream(path, FileMode.Create, FileAccess.Write); Log.GetInstance().WriteLine("Downloading Video..."); } Log.GetInstance().WriteLine(fragment.PercentComplete.ToString(".0") + "%"); Debug.Assert(_videoFile != null); _videoFile.Write(fragment.Buffer, 0, fragment.Buffer.Length); if (fragment.IsLast) { _videoFile.Close(); _videoFile = null; Log.GetInstance().WriteLine("Saved Video: " + path + " (" + fragment.VideoWidth + "x" + fragment.VideoHeight + ")"); } }