萤石云 iOSSDK,移植跨平台相关工程
JLChen
2021-08-06 edc0f0a0439f9e5a11593e21a4779fa6dbcbe49d
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//
//  EZLocalRealPlayViewController.m
//  EZOpenSDKDemo
//
//  Created by linyong on 2017/8/16.
//  Copyright © 2017年 Ezviz. All rights reserved.
//
 
#import "EZLocalRealPlayViewController.h"
#import "EZPlayer.h"
#import "EZHCNetDeviceSDK.h"
#import "EZHCNetDeviceInfo.h"
 
@interface EZLocalRealPlayViewController () <EZPlayerDelegate>
 
@property (weak, nonatomic) IBOutlet UIView *playerView;
@property (weak, nonatomic) IBOutlet UIButton *ptzBgBtn;
@property (weak, nonatomic) IBOutlet UIButton *ptzUpBtn;
@property (weak, nonatomic) IBOutlet UIButton *ptzDownBtn;
@property (weak, nonatomic) IBOutlet UIButton *ptzRightBtn;
@property (weak, nonatomic) IBOutlet UIButton *ptzLeftBtn;
@property (nonatomic,strong) EZPlayer *player;
 
@end
 
@implementation EZLocalRealPlayViewController
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title = NSLocalizedString(@"device_lan_preview_title", @"局域网预览");
    
    [self startRealPlay];
    // Do any additional setup after loading the view.
}
 
- (void) viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.player stopRealPlay];
}
 
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
 
#pragma mark - ptz action
 
- (IBAction)ptzStart:(id)sender
{
    EZPTZCommandType command;
    NSString *imageName = nil;
    if(sender == self.ptzLeftBtn)
    {
        command = EZPTZCommandType_LEFT;
        imageName = @"ptz_left_sel";
    }
    else if (sender == self.ptzDownBtn)
    {
        command = EZPTZCommandType_DOWN;
        imageName = @"ptz_bottom_sel";
    }
    else if (sender == self.ptzRightBtn)
    {
        command = EZPTZCommandType_RIGHT;
        imageName = @"ptz_right_sel";
    }
    else {
        command = EZPTZCommandType_UP;
        imageName = @"ptz_up_sel";
    }
    
    [self.ptzBgBtn setImage:[UIImage imageNamed:imageName] forState:UIControlStateDisabled];
    [self ptzWithCommand:command action:EZPTZActionType_START];
}
 
- (IBAction)ptzStop:(id)sender
{
    EZPTZCommandType command;
    if(sender == self.ptzLeftBtn)
    {
        command = EZPTZCommandType_LEFT;
    }
    else if (sender == self.ptzDownBtn)
    {
        command = EZPTZCommandType_DOWN;
    }
    else if (sender == self.ptzRightBtn)
    {
        command = EZPTZCommandType_RIGHT;
    }
    else {
        command = EZPTZCommandType_UP;
    }
    [self.ptzBgBtn setImage:[UIImage imageNamed:@"ptz_bg"] forState:UIControlStateDisabled];
    [self ptzWithCommand:command action:EZPTZActionType_STOP];
}
 
#pragma mark - player delegate
 
- (void)player:(EZPlayer *)player didPlayFailed:(NSError *)error
{
    NSLog(@"local player error :%@",error);
}
 
- (void)player:(EZPlayer *)player didReceivedMessage:(NSInteger)messageCode
{
 
}
 
#pragma mark - support
 
- (void) startRealPlay
{
    self.player = [EZPlayer createPlayerWithUserId:self.deviceInfo.userId cameraNo:self.cameraNo streamType:1];
    
    [self.player setPlayerView:self.playerView];
    self.player.delegate = self;
    
    [self.player startRealPlay];
}
 
- (void) ptzWithCommand:(EZPTZCommandType) command action:(EZPTZActionType) action
{
    [EZHCNetDeviceSDK ptzControlWithUserId:self.deviceInfo.userId channelNo:self.cameraNo command:command action:action];
}
 
@end