Jak w temacie.
Przy kompilacji mam błąd:
Exception in thread "main" java.lang.NullPointerException
at klatka.main(klatka.java:35)
Prawdopodobnie chodzi tu o to ze mi sie player nie tworzy ale nie wiem dlaczego.
Co tu jest nie tak? Prosze o pomoc.
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.media.*;
import javax.media.control.*;
import javax.media.format.*;
import javax.media.util.*;
import java.io.File;
import java.net.URL;
import javax.media.Manager;
import javax.media.Player;
public class klatka
{
public static void main(String[] args) throws Exception
{
Player player = Manager.createRealizedPlayer (new URL("file:///c:/form.mpg"));
player.start();
Thread.sleep(2500);
// Grab a frame from the capture device
FrameGrabbingControl frameGrabber = (FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");
Buffer buf = frameGrabber.grabFrame();
// Convert frame to an buffered image so it can be processed and saved
Image img = (new BufferToImage((VideoFormat)buf.getFormat()).createImage(buf));
BufferedImage buffImg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D g = buffImg.createGraphics();
g.drawImage(img, null, null);
// Overlay curent time on image
g.setColor(Color.RED);
g.setFont(new Font("Verdana", Font.BOLD, 16));
```java
g.drawString((new Date()).toString(), 10, 25);
// Save image to disk as PNG
ImageIO.write(buffImg, "png", new File("c:///screenshot.png"));
// Stop using webcam
player.close();
player.deallocate();
System.exit(0);
}
}