0% found this document useful (0 votes)
64 views2 pages

Public Class Video Extends Javax

This document defines a Java class called "video" that extends the JFrame class. It initializes a jmfVideo object and sets properties of the JFrame like the title, size, and layout. It adds the component returned by jmfVideo's Componente() method to display the video stream. The jmfVideo class implements methods to access the webcam video stream using JMF, get the video component, and handle exceptions if the stream cannot be accessed.

Uploaded by

Jorch Ricardo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views2 pages

Public Class Video Extends Javax

This document defines a Java class called "video" that extends the JFrame class. It initializes a jmfVideo object and sets properties of the JFrame like the title, size, and layout. It adds the component returned by jmfVideo's Componente() method to display the video stream. The jmfVideo class implements methods to access the webcam video stream using JMF, get the video component, and handle exceptions if the stream cannot be accessed.

Uploaded by

Jorch Ricardo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

public class video extends javax.swing.

JFrame { jmfVideo b = new jmfVideo(); /** Creates new form video */ public video() { initComponents(); this.setTitle("WebCam - by Mouse"); //formulario al centro de la pantalla this.setLocationRelativeTo(null); //se da un tamao al jFrame this.setSize(320, 240); //se coloca un layout tipo CAJA getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS)); //se aade el componente de video this.add( b.Componente()); }

import java.util.logging.Level; import java.util.logging.Logger; import javax.media.*; import javax.media.cdm.CaptureDeviceManager; import java.io.*; import java.awt.*; import javax.swing.JOptionPane; /** * @web http://jc-mouse.blogspot.com/

* @author Mouse */ public class jmfVideo { //Controlador universal de windows private String dispositivo = "vfw:Microsoft WDM Image Capture (Win32):0"; private Player player = null; public Component Componente(){ Component componente_video; try { // Se obtiene el dispositivo CaptureDeviceInfo device = CaptureDeviceManager.getDevice(dispositivo); //se obtiene la fuente de datos de captura MediaLocator localizador = device.getLocator(); //El localizador es del tipo "vfw://0" video para windows //se crea el PLAYER y se ejecuta player = Manager.createRealizedPlayer(localizador); player.start(); } catch (IOException ex) { Logger.getLogger(jmfVideo.class.getName()).log(Level.SEVERE, null, ex); } catch (NoPlayerException ex) { Logger.getLogger(jmfVideo.class.getName()).log(Level.SEVERE, null, ex); } catch (CannotRealizeException ex) { Logger.getLogger(jmfVideo.class.getName()).log(Level.SEVERE, null, ex); } //Si se pudo crear el PLAYER, se obtiene el componente de video if ((componente_video = player.getVisualComponent()) != null) { //se da un tamao al componente componente_video.setSize(320, 240); return componente_video; } else { JOptionPane.showMessageDialog(null,"No se pudo crear el video..."); return null; } } }

You might also like