fuliqi
2024-08-29 4163c93761115c7524ef74a557a1f5e01eafb429
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.ycl.api.YS.liveview.live;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.util.Common;
 
import javax.swing.*;
import java.io.File;
 
/**
 * 
 * @introduction Video Record
 * @description  Support IPC/NVR/VMS
 */
public class Record {
    
    /**
     * 
     * @introduction Start save the video to the local working directory
     * @description Calling the interface of NETDEV_SaveRealData to save the video to the local working directory
     *
     */
    public static void startRecord() {
        if(null == NetDemo.lpUserID)
        {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        if(null != NetDemo.lpPlayHandle){
            String strSeparator = File.separator;
            NetDemo.strRecordPath = System.getProperty("user.dir").replaceAll("%20"," ") + strSeparator+"Record"+strSeparator+"test" + Common.timeStamp() + "_D"+NetDemo.ChannelID;
            boolean bRet = NetDemo.netdevsdk.NETDEV_SaveRealData(NetDemo.lpPlayHandle, NetDemo.strRecordPath, 0);
            if(!bRet){
                JOptionPane.showMessageDialog(null, "Start Record failed.Please check the path.");
            }
            else{
                NetDemo.bStartRecord = true;
                NetDemo.jButtonStopRecord.setEnabled(true);
                NetDemo.jButtonStartRecord.setEnabled(false);
            }
        }else{
            JOptionPane.showMessageDialog(null, "Please start live first.");
        }
    
    }
 
    /**
     * 
     * @introduction  Stop saving the video to the local working directory
     * @description Calling the interface of NETDEV_StopSaveRealData to stop saving the video to the local working directory
     *
     */
    public static void stopRecord() {
        if(NetDemo.bStartRecord){
            boolean bRet = NetDemo.netdevsdk.NETDEV_StopSaveRealData(NetDemo.lpPlayHandle);
            NetDemo.bStartRecord = false;
            if(!bRet){
                JOptionPane.showMessageDialog(null, "StopRecord failed.Please check the path.");
            }
            else{
                NetDemo.jButtonStopRecord.setEnabled(false);
                NetDemo.jButtonStartRecord.setEnabled(true);
                JOptionPane.showMessageDialog(null, NetDemo.strRecordPath);
            }
        }else{
            JOptionPane.showMessageDialog(null, "Start StartRecord, please.");
        }
    
    }
}