/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apps.user.gui;
 
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JFrame;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
 
/**
 *
 * @author Dedy
 */
 
public class CctvUser extends javax.swing.JFrame {
    /**
     * 
     */
    public final EmbeddedMediaPlayerComponent mediaPlayerComponent;
 
     /**
      * 
      */
     public CctvUser() {                
         JFrame frame = new JFrame("Closed Circuit Television (CCTV)"); 
         frame.setIconImage(new javax.swing.ImageIcon(getClass().getResource("/apps/user/image/cctv.png")).getImage());//Memberi favicon di jframe   
         frame.setSize(1050, 600);
         frame.setVisible(true);                      
         
         NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files/VideoLAN/VLC");//Load dll vlc
         Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);           
         
         mediaPlayerComponent = new EmbeddedMediaPlayerComponent();   
         frame.setContentPane(mediaPlayerComponent);                                
         File dir = new File(System.getProperty("user.home"), "Videos");
         dir.mkdirs(); // HOW TO SAVE TO URL FOR EXAMPLE http://192.168.1.1/Test
         DateFormat df = new SimpleDateFormat("yyyyMMdd-HHmmss");
         String fileName = dir.getAbsolutePath() + "/Capture-" + df.format(new Date()) + ".mpeg";          
         String [] options =  {":sout=#transcode{vcodec=mpgv,vb=4094,scale=1,acodec=mpg,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=" + fileName + "},dst=display}"};
         mediaPlayerComponent.getMediaPlayer().playMedia("http://192.193.194.195/2.MP4",options);//Dapat mendukung beberapa protocol
     }
}