zxl
23 小时以前 3b0516a2959e25576e4f3fda697a3b025d06c8c9
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
package com.ycl.api.YS.liveview.live;
 
import com.ycl.api.YS.NetDemo;
 
import javax.swing.*;
 
/**
 * 
 * @introduction Open/Close Microphone
 * @description Support special device with voice intercom
 */
public class Microphone {
    
    /**
     * 
     * @introduction Open/Close Microphone
     * @description Calling the interface of NETDEV_OpenMic or NETDEV_CloseMic
     *
     */
    public static void changeMicrophoneState() {
        if(null == NetDemo.lpUserID){
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }  
        if(NetDemo.lpTalkHandle!=null) {
            if(NetDemo.state==0) {
                boolean bRet= NetDemo.netdevsdk.NETDEV_OpenMic(NetDemo.lpTalkHandle);
                if(bRet) {
                    NetDemo.state=1;    
                    NetDemo.jSliderLiveMicSound.setEnabled(true);
                    if(NetDemo.lpTalkHandle!=null) {
                        if(NetDemo.jLableLiveMicSound.getText().equals("0")) {
                            NetDemo.netdevsdk.NETDEV_CloseMic(NetDemo.lpTalkHandle);
                        } else {
                            NetDemo.netdevsdk.NETDEV_OpenMic(NetDemo.lpTalkHandle);
                        }
                    }
                }else {
                    JOptionPane.showMessageDialog(null, "Open Microphone Failed"+NetDemo.netdevsdk.NETDEV_GetLastError());
                    System.out.println("NETDEV_OpenMic failed" +NetDemo.netdevsdk.NETDEV_GetLastError());
                    NetDemo.jSliderLiveMicSound.setEnabled(false);
                    return;
                }
            }else if(NetDemo.state==1){
                boolean bRet= NetDemo.netdevsdk.NETDEV_CloseMic(NetDemo.lpTalkHandle);
                if(bRet) {
                    NetDemo.state=0;
                    NetDemo.jSliderLiveMicSound.setEnabled(false);
                    NetDemo.netdevsdk.NETDEV_SetMuteStatus(NetDemo.lpTalkHandle,0);
                    NetDemo.netdevsdk.NETDEV_OpenSound(NetDemo.lpTalkHandle);    
                }else {
                    JOptionPane.showMessageDialog(null,"Close Microphone failed,error code" +NetDemo.netdevsdk.NETDEV_GetLastError());
                    System.out.println("NETDEV_CloseMic failed" +NetDemo.netdevsdk.NETDEV_GetLastError());
                    return;
                }
            }
        }
    }
}