public override void WindowControllerDidLoadNib(NSWindowController windowController) { NSError err; // Create a movie, and store the information in memory on an NSMutableData movie = new QTMovie(new NSMutableData(1), out err); if (movie == null) { NSAlert.WithError(err).RunModal(); return; } movieView.Movie = movie; // Find video device captureSession = new QTCaptureSession(); var device = QTCaptureDevice.GetDefaultInputDevice(QTMediaType.Video); if (device == null) { new NSAlert { MessageText = "You do not have a camera connected." }.BeginSheet(windowController.Window); return; } else if (!device.Open(out err)) { NSAlert.WithError(err).BeginSheet(windowController.Window); return; } // Add device input captureInput = new QTCaptureDeviceInput(device); if (!captureSession.AddInput(captureInput, out err)) { NSAlert.WithError(err).BeginSheet(windowController.Window); return; } // Create decompressor for video output, to get raw frames decompressedVideo = new QTCaptureDecompressedVideoOutput(); decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) { lock (this) { currentImage = e.VideoFrame; } }; if (!captureSession.AddOutput(decompressedVideo, out err)) { NSAlert.WithError(err).BeginSheet(windowController.Window); return; } // Activate preview captureView.CaptureSession = captureSession; // Start running. captureSession.StartRunning(); }
/// <summary> /// Removes all quicktime event listeners for the quicktime QTMovie movie /// </summary> /// <param name="myMovie">The movie to remove the listeners from</param> private void removeMovieEventListeners(QTMovie myMovie) { // Make sure movie is loaded if (myMovie != null) { // Remove all event listeners myMovie.EventListeners.RemoveAll(); } }
/// <summary> /// Specifies and adds the quicktime movie events (pause, play etc) to a quicktime movie. Anything that then listens to the QTEvent event will then pick up these events. /// </summary> /// <param name="myMovie">The movie to add the listeners to</param> private void addMovieEventListeners(QTMovie myMovie) { // Make sure movie is loaded if (myMovie == null) { return; } // rate change listener (pause, play) myMovie.EventListeners.Add(QTEventClassesEnum.qtEventClassStateChange, QTEventIDsEnum.qtEventRateWillChange, 0, null); myMovie.EventListeners.Add(QTEventClassesEnum.qtEventClassStateChange, QTEventIDsEnum.qtEventMovieDidEnd); }
private void PlatformDispose(bool disposing) { if (MovieView != null) { MovieView.Dispose(); MovieView = null; } if (_mMovie != null) { _mMovie.Dispose(); _mMovie = null; } }
public void Dispose() { if (mMovieView != null) { mMovieView.Dispose(); mMovieView = null; } if (mMovie != null) { mMovie.Dispose(); mMovie = null; } }
public override void WindowControllerDidLoadNib (NSWindowController windowController) { NSError err; // Create a movie, and store the information in memory on an NSMutableData movie = new QTMovie (new NSMutableData (1), out err); if (movie == null) { NSAlert.WithError (err).RunModal (); return; } movieView.Movie = movie; // Find video device captureSession = new QTCaptureSession (); var device = QTCaptureDevice.GetDefaultInputDevice (QTMediaType.Video); if (device == null) { new NSAlert { MessageText = "You do not have a camera connected." }.BeginSheet (windowController.Window); return; } else if (!device.Open (out err)) { NSAlert.WithError (err).BeginSheet (windowController.Window); return; } // Add device input captureInput = new QTCaptureDeviceInput (device); if (!captureSession.AddInput (captureInput, out err)) { NSAlert.WithError (err).BeginSheet (windowController.Window); return; } // Create decompressor for video output, to get raw frames decompressedVideo = new QTCaptureDecompressedVideoOutput (); decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) { lock (this) { currentImage = e.VideoFrame; } }; if (!captureSession.AddOutput (decompressedVideo, out err)) { NSAlert.WithError (err).BeginSheet (windowController.Window); return; } // Activate preview captureView.CaptureSession = captureSession; // Start running. captureSession.StartRunning (); }
public override bool ReadFromUrl(NSUrl absoluteUrl, string typeName, out NSError outError) { var loaded = QTMovie.FromUrl(absoluteUrl, out outError); if (loaded != null) { loaded.SetAttribute(NSNumber.FromBoolean(true), QTMovie.EditableAttribute); if (movie != null) { movie.Dispose(); } movie = loaded; } return(loaded != null); }
private void PlatformInitialize() { var err = new NSError(); _mMovie = new QTMovie(FileName, out err); if (_mMovie != null) { MovieView = new QTMovieView(); MovieView.Movie = _mMovie; MovieView.IsControllerVisible = false; } else { Console.WriteLine(err); } }
internal void Prepare() { NSError err = new NSError(); mMovie = new QTMovie(_fileName, out err); if (mMovie != null) { mMovieView = new QTMovieView(); mMovieView.Movie = mMovie; mMovieView.IsControllerVisible = false; } else { Console.WriteLine(err); } }
public override void WindowControllerDidLoadNib(NSWindowController windowController) { base.WindowControllerDidLoadNib(windowController); // A reference to the window controller must be kept on the managed side // to keep the object from being GC'd so that the delegates below resolve. // Don't remove unless the framework is updated to track the reference. this.windowController = windowController; NSError err; windowController.Window.WillClose += delegate { if (captureSession != null) { captureSession.StopRunning(); } var dev = captureInput.Device; if (dev.IsOpen) { dev.Close(); } }; // Create a movie, and store the information in memory on an NSMutableData movie = new QTMovie(new NSMutableData(1), out err); if (movie == null) { NSAlert.WithError(err).RunModal(); return; } movieView.Movie = movie; // Find video device captureSession = new QTCaptureSession(); var device = QTCaptureDevice.GetDefaultInputDevice(QTMediaType.Video); if (!device.Open(out err)) { NSAlert.WithError(err).RunModal(); return; } // Add device input captureInput = new QTCaptureDeviceInput(device); if (!captureSession.AddInput(captureInput, out err)) { NSAlert.WithError(err).RunModal(); return; } // Create decompressor for video output, to get raw frames decompressedVideo = new QTCaptureDecompressedVideoOutput(); decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) { lock (this){ currentImage = e.VideoFrame; } }; if (!captureSession.AddOutput(decompressedVideo, out err)) { NSAlert.WithError(err).RunModal(); return; } // Activate preview captureView.CaptureSession = captureSession; // Start running. captureSession.StartRunning(); }
// remove all event listeners for the movie private void removeMovieEventListeners(QTMovie myMovie) { // Make sure a movie is loaded first if (myMovie != null) { // Remove all event listeners myMovie.EventListeners.RemoveAll(); } }
private void addMovieEventListeners(QTMovie myMovie) { // Contains code to demonstrate how to add listeners // for various QuickTime Events // Make sure a movie is loaded first if (myMovie == null) return; // status string listener myMovie.EventListeners.Add(QTOLibrary.QTEventClassesEnum.qtEventClassApplicationRequest, QTOLibrary.QTEventIDsEnum.qtEventShowStatusStringRequest, 0, null); // rate change listener myMovie.EventListeners.Add(QTOLibrary.QTEventClassesEnum.qtEventClassStateChange, QTOLibrary.QTEventIDsEnum.qtEventRateWillChange, 0, null); // time change listener myMovie.EventListeners.Add(QTOLibrary.QTEventClassesEnum.qtEventClassTemporal, QTOLibrary.QTEventIDsEnum.qtEventTimeWillChange, 0, null); // audio volume change listener myMovie.EventListeners.Add(QTOLibrary.QTEventClassesEnum.qtEventClassAudio, QTOLibrary.QTEventIDsEnum.qtEventAudioVolumeDidChange, 0, null); }
// Get the specified annotation from the movie private string MovieAnnotation(int inAnnoID, QTMovie inMovie) { string anno = string.Empty; if (inMovie != null) { try { // get movie annotation anno = inMovie.get_Annotation(inAnnoID); } catch { // an error here means movie does not contain // the desired annotation } } return anno; }
// Set the active movie for our info. display public void SetInfoMovie(QTMovie inMovie) { m_movie = inMovie; DisplayMovieData(); }
public override bool ReadFromUrl (NSUrl url, string typeName, out NSError outError) { var loaded = QTMovie.FromUrl (url, out outError); if (loaded != null) { loaded.SetAttribute (NSNumber.FromBoolean (true), QTMovie.EditableAttribute); if (movie != null) movie.Dispose (); movie = loaded; } return loaded != null; }
/// <summary> /// Specifies and adds the quicktime movie events (pause, play etc) to a quicktime movie. Anything that then listens to the QTEvent event will then pick up these events. /// </summary> /// <param name="myMovie">The movie to add the listeners to</param> private void addMovieEventListeners(QTMovie myMovie) { // Make sure movie is loaded if (myMovie == null) return; // rate change listener (pause, play) myMovie.EventListeners.Add(QTEventClassesEnum.qtEventClassStateChange, QTEventIDsEnum.qtEventRateWillChange, 0, null); myMovie.EventListeners.Add(QTEventClassesEnum.qtEventClassStateChange, QTEventIDsEnum.qtEventMovieDidEnd); }