-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
webcam-capture/src/example/java/com/github/sarxos/webcam/WebcamDiscoveryListenerExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
public class WebcamDiscoveryListenerExample implements WebcamDiscoveryListener { | ||
|
||
public WebcamDiscoveryListenerExample() { | ||
for (Webcam webcam : Webcam.getWebcams()) { | ||
System.out.println("This webcam has been found in the system: " + webcam.getName()); | ||
} | ||
Webcam.addDiscoveryListener(this); | ||
System.out.println("Now, please connect additional webcam, or disconnect already connected one."); | ||
} | ||
|
||
@Override | ||
public void webcamFound(WebcamDiscoveryEvent event) { | ||
System.out.println("Oh! Thou, webcam has been connected! " + event.getWebcam().getName()); | ||
} | ||
|
||
@Override | ||
public void webcamGone(WebcamDiscoveryEvent event) { | ||
System.out.println("Did I miss something? Webcam has been disconnected! " + event.getWebcam().getName()); | ||
} | ||
|
||
public static void main(String[] args) throws Throwable { | ||
new WebcamDiscoveryListenerExample(); | ||
Thread.sleep(120000); | ||
System.out.println("Bye!"); | ||
} | ||
} |