fuliqi
2025-02-21 64efb660b2c119c00432434c0f651f8996483f18
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
70
71
72
73
74
75
76
package com.ycl.api.YS.liveview.live;
 
import com.sun.jna.ptr.IntByReference;
import com.ycl.api.YS.NetDemo;
 
import javax.swing.*;
import javax.swing.event.ChangeEvent;
 
/**
 * 
 * @introduction Change sound
 * @description Support IPC/NVR/VMS
 */
public class SoundVolume {
    
    /**
     * 
     * @introduction Change live preview sound
     * @description Calling the interface of NETDEV_SoundVolumeControl
     *
     */
    public static void changeLiveSound(ChangeEvent e) {  
        int volume=((JSlider)e.getSource()).getValue();
        IntByReference pdwVolume=new IntByReference();
        boolean bRet=NetDemo.netdevsdk.NETDEV_GetSoundVolume(NetDemo.lpPlayHandle, pdwVolume);
        NetDemo.netdevsdk.NETDEV_GetSoundVolume(NetDemo.lpTalkHandle, pdwVolume);
        if(bRet) {
            NetDemo.jLabelLiveSound.setText(String.valueOf(pdwVolume.getValue()));
            if(NetDemo.lpTalkHandle!=null) {
                NetDemo.netdevsdk.NETDEV_SoundVolumeControl(NetDemo.lpTalkHandle,pdwVolume.getValue());
            }
            boolean bRet2=NetDemo.netdevsdk.NETDEV_SoundVolumeControl(NetDemo.lpPlayHandle,pdwVolume.getValue());
            if(bRet2) {
                NetDemo.jLabelLiveSound.setText(String.valueOf(volume));
                NetDemo.netdevsdk.NETDEV_SoundVolumeControl(NetDemo.lpTalkHandle,volume);
                NetDemo.netdevsdk.NETDEV_SoundVolumeControl(NetDemo.lpPlayHandle,volume);
            }else {
                JOptionPane.showMessageDialog(null, "Play sound failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                return;
            }
        }else {
            NetDemo.jLabelLiveSound.setText(String.valueOf(volume));
            NetDemo.netdevsdk.NETDEV_SoundVolumeControl(NetDemo.lpTalkHandle,volume);
            NetDemo.netdevsdk.NETDEV_SoundVolumeControl(NetDemo.lpPlayHandle,volume);
        }
    
    }
 
    /**
     * 
     * @introduction Change microphone sound
     * @description Calling the interface of NETDEV_MicVolumeControl
     *
     */
    public static void changeMicrophoneSound(ChangeEvent e) {
        int volume=((JSlider)e.getSource()).getValue();
        IntByReference pdwVolume=new IntByReference();
            if(NetDemo.lpTalkHandle!=null) {
                boolean bRet=NetDemo.netdevsdk.NETDEV_GetMicVolume(NetDemo.lpTalkHandle,pdwVolume);
                if(bRet) {
                    NetDemo.jLableLiveMicSound.setText(String.valueOf(pdwVolume.getValue()));
                    boolean bRet2=NetDemo.netdevsdk.NETDEV_MicVolumeControl(NetDemo.lpTalkHandle, pdwVolume.getValue());
                    if(bRet2) {
                        NetDemo.jLableLiveMicSound.setText(String.valueOf(volume));
                        NetDemo.netdevsdk.NETDEV_MicVolumeControl(NetDemo.lpTalkHandle, volume);
                    }else {
                        JOptionPane.showMessageDialog(null, "Play sound failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                        return;
                    }
                }else {
                    NetDemo.jLableLiveMicSound.setText(String.valueOf(volume));
                    NetDemo.netdevsdk.NETDEV_MicVolumeControl(NetDemo.lpTalkHandle, volume);
                    }
                }   
            }
    }