SDEASYCAM 手机APP软件 前30页代码.docx

上传人:李司机 文档编号:4294338 上传时间:2023-04-14 格式:DOCX 页数:29 大小:74.96KB
返回 下载 相关 举报
SDEASYCAM 手机APP软件 前30页代码.docx_第1页
第1页 / 共29页
SDEASYCAM 手机APP软件 前30页代码.docx_第2页
第2页 / 共29页
SDEASYCAM 手机APP软件 前30页代码.docx_第3页
第3页 / 共29页
SDEASYCAM 手机APP软件 前30页代码.docx_第4页
第4页 / 共29页
SDEASYCAM 手机APP软件 前30页代码.docx_第5页
第5页 / 共29页
点击查看更多>>
资源描述

《SDEASYCAM 手机APP软件 前30页代码.docx》由会员分享,可在线阅读,更多相关《SDEASYCAM 手机APP软件 前30页代码.docx(29页珍藏版)》请在三一办公上搜索。

1、#importMKHorizMenu.h#defineKButtonBaseTag10000#defineKLeftOffset5implemeniationMKHorizMenuSyntheSiZetitles=Jitles;synthesizeSelectedlmage-_selectedlmage;synthesizeitemSelectedDelegate;SyZheSiZedataSource:SynmeSiZeitemCount=JtemCount;-(void)awakeFromNib(self.bonces=YES;self.scrollEnabled=YES;self.alw

2、aysBounceHorizontalYES;self.alwaysBounceVertical=NO;Self.ShowsHorizontaiscroIIIndicator=NO;Self-ShowsverticaiscrolllndicatorNO;SeIfreloadData;-(void)TeIoadSoundBtn()-(void)reloadData(NSArray*viewsToRemove-selfsubviews;for(UIView*vinViewsToRemove)vremoveFromSperview);)SeIfJtemCount=dataSourcenumberOf

3、ltemsForMenu:self;self.backgroundColor=dataSourcebackgroundColorForMenuzself;/Self.Selectedlmage=dataSourceSelecteclltemImageForMenuiseIf;UIFont*buttonFont=(UIFontboldSystemFonlOfSizer15;intbultoPadding-5;inttag=KButtonBaseTag;intxPosRLeftOffset;CGFIoatbtnTotalWidth=O.Of;for(inti=O;iself.itemCount;i

4、+)Ullmage*bglmg=UllmageimageNamed:dataSourcehorizMenu:selftitleForltemAtlndex:i;btnTotalWidth+=bgImg.size.width;if(i3)NSLog(OK);)计算左右变距CGFIoattotalLen=(self.itemCount-1)*buttonPadding+btnTotalWidth;CGFIoatleft-(self.superview.frame.size.width-totalLe)2;f(leftXO)IeftX=XPos;XPos=IeftX;for(intiO;iself.

5、itemCount;i+)(NSString,title=UIButton*customButtonUIButtonbuttonWithTypeUIBultonTypeCuslom;CustomButtonsetTitle:titleforState:UIControlStateNormal;CustomButtonJitleLabeLfont=buttonFont;Ullmage*bglmg=UllmageimageNamed:dataSourcehorizMenu:selftitleForltemAtlndex:i:(CustomButtonSetBackgroundImagerbgImg

6、forState:UIcontroIStateNormaI;CustomButtonsetBackgroundlmage:UllmageimageNamedJdatasourceselectedltemlmageForMenuiseIfitemAtIndexiiforState:UIcontroIStateSeIected;(CustomButtonsetBackgroundlmage:UllmageimageNamed:dataSourceselectedltemlmageForMenu:selfitemAtlndex:iforState:IJlContrOIStaIeHighlighted

7、;CustomButtonJag=tag+;CustomButtonaddTarget:selfaction:selector(buttonTapped:)forControlEvents:UIControlEventTouchUplnside;CustomButtonaddTarget:selfaction:selector(buttonTouchDown:)forControlEvents:UIControlEventTouchDown:CustomButtonJrame-CGRectMake(xPos,3,bglmg.size.width,38):Pos+=bglmg.size.widt

8、h;if(i1self.itemCount)xPos+=buttonPadding;sefaddSubviewxustomButto;xPos+=IeftX:if(xPosself.frame.size.width)xPos-self.frame.size.width;self.cotentSize=CGSizeMake(Pos,self.frame.size.height);(SelflayoutSubviews;)#import#import#importCameraMultiLiveViewController.h#import#importVloTCamera/ImageBufflnf

9、o.h#import#import#importAppDelegate.h#import*MyNavViewController.himport-UIDevice+Device,h#defineDEF_WAIT4ST0PSH0W_TIME250#CIefineDEF-SplitViewNm4#defineDEFReTryConnectlnterval25*1000#defineDEF_ReTryTimes10interfaceCameraMultiLiveViewController()MyCamera*mDummyCam:NSMutabIeArray,marlmg-Vdo:intmReTry

10、TimesArrayDEFSpIitViewNum;UnsignedintmnLastReTryTickArray(DEF-SplitViewNum;)end(implementationCameraMultiLiveviewControIIerSynmeSiZebStopShowCompletedLock;synthesizeSelectedAudioMode;SyntheSiZecamNeedReconnect;synthesizeSeIectCameraArray;synthesizeCameraArray;SyntheSiZeChanneIArray;#PragmamarkMethod

11、s-(Ullnterfaceorientation)PreferredlnterfaceorienlationForPresentation(returnUllntertaceOrientationLandscapeLeft;)(CGRect)ZoomRectForscroliviewxuiscroIIView*)_scrollViewwithScale:(CGFIoat)scaleWithCenter:(CGPoint)CenterCGReclzoomRect:HThezoomrectisinthententviewsordinates.HAtazoomscaleof1.0.itwouldb

12、ethesizeofIhe/imageScrollView,sbounds.HAsthezoomscaledecreases,somorententisvisible,hesizeoftherectgrows.ZoomReCISiZe.height=_scrollView.frame.size.height/scale;zoomRect.size.width=scrollView.frame.size.width/scale;Uchooseanoriginsoastogettherightcenter.zoomRct.origin.x=center.x-(zoomRect.size.width

13、/2.0);zmRect.origin.y=center.y-(zoomRect.size.height/2.0);returnzoomRect;)-(Ullmage*)getUllmage:(char*)buffWidth:(NSInteger)WidthHeight:(NSInteger)heightCGDataProviderRefprovider=CGDataPrOViderereateWithData(NULL,buff,width*height*3tNULL);CGcoIorSpaceRefcolorspace=CGColorSpaceCreatDeviceRGB():CGlmag

14、eRefimgRef=CGlmageCreat(width,height,8l24,width*3,colorSpace1kCGBitmapByteOrderDefaut,provider,NULL,true,kCGRenderingIntentDefauIt);Ullmage*img=UIImageimageWithCGImagejmgRef;f(imgRef!=nil)(CGImageRelease(imgRef);imgRef=nil;if(colorSpace!=nil)CGcolorspaceRelease(CoIorSpace);lorSpace=nil;f(providerlni

15、l)CGDataPrOViderReleaSe(ProVider);provider-nil;returnimgcopyautorelease;)-(void)camStopShowr(int)algnoreldxisCamStopShow=YES:for(inti-O;iDEF_SplitViewNum;i+)if(i=algnored)continue;MyCamera*testCamera=(CameraArrayobjectAtIndexzi;if(testCamera.id!=nil&!testCamera.uidisEqualToString:(null)NSNumber*temp

16、ChannelChanneIArrayobjectAtIndex:1;if(testCamera.sssionState=CONNECTIONSTATE_CONNECTED&(testCameragetConnectionStateOfChannel:0=CONNECTION_STATE_CONNECTED)testCamera.isShowlnMltiView=NO;testCamerastopShow:tempChannelintVaue;)-(void)reStartShowisCamStopShowNO;for(inti=0jiDEFSpIitViewNum;i+)MyCamera*t

17、empCamera=CameraArrayobjectAtldex:i;if(tempCamera.uid!=nil<empCamera.uidisEqualToString:*(null)N)(NSNumbertempChannel=ChanneIArrayobjectAtIndex:1;if(tempCamera.sessionStateCONNECTION_STATE_CONNECTED&temCameragetConnectionStateOfChannekOCONNECTION_STATE_CONNECTED)if(!isGoPlayEvent)tempCamera.isShow

18、lnMultiViewYES;(tempCameraStartShoWjtempChanneIIntegerVaIueJScreenObjectiseIf;)-(vod)reConnectAndShowfor(inti=O;iDEF_SplitViewNum;i+)MyCamera*tempCameracameraArrayObjectAtIndex:i;if(tempCamera.uid!=nil&!tempCamera.uidisEqualToString:(null)ChanneIArrayobjectAtIndex:1;SelfdisconnectCameralempCamera.Ui

19、d;tempCameradisconnect:tempCameraconnect:tempCamera.uidJ;tempCamerastartz;if(!isGoPlayEvent)tempCamera.isShowlMultiViewYES;/tempCamerastartShow:0ScreenObject:self;)tempCamera.delegate2=self;)-(void)disnnectCameraNSStrig)strUID(for(inti=0;iDEFSpIitViewNum;i+)MyCamera*cam-CameraArrayobjectAtIndex:1);N

20、SNumber*numChannel=ChannelArrayobjectAtIndexJ:if(cam.uidisEqualToString:strUID)camstop:numChannelintValue;)进入播放界面(IBAction)goLiveView:(id)sender(intnld=(int)(UIView*)sendertag;MyCameraVempCamera=CameraArrayobjectAtIndex:nld;if(tempCamera.uid!=nil&!(tempCamera.uidisEqualToString:(null)&(tempCamera.Se

21、SSionState=CONNECTION_STATE_CONNECTED&tempCameragetConnectionStateOfChannel:0=CONNECTION_STATE_CONNECTED)ntchannel=(int)channelArrayobjectAtlndex:nldxintVaue;SelfcamStopShow:nldx;CameraLiveviewControIIer,controller=(CameraLiveViewControllerallocinitWithNibName:CameraLiveViewbundle:nil;controller.cam

22、eratempCamera;ControIIer.ViewTag=NSNumbernumberWithlnt:(int)(UIView*)sendertag;cotroller.delegate=self;ControIIer-SelectedChannel=channel;UlNavigationControIIer*customNavControllerMyNavViewControllerallocinit:SelfpresentviewcontrollerrcustomNavControIIeranimated:YESOOmPlelion:nil;(CustomNavControIIe

23、rpushViewControllerxontrolleranimatedzYES;controllerrelease;(CustomNavControIIerrelease;)返回摄像机列表界面-(void)backMyCamera(AppDeIegateappDelegate(AppDeIegate*)(UIApplicationsharedApplication.delegate;appDelegate.allowRotatio=O;for(inti-O;iDEF_SplitViewNum;i+)(MyCamera,cameraldx=CameraArrayobjectAtIndexj;

24、cameraldsi。PShoW:0;)selfdismissViewControllerAnimatecl:YEScompIetion:nil;)#Pragmamark-Viewlifecycle-(vod)dealloc(Lvdoirelease;Lvdo2release:vdo3releas;Lvdo4release;(marrlmg-Vdorelease;mDummyCamrelease;(superdealloc);)-(void)viewWillLayoutSbviews(SuperviewWilILayoUtSUbViews;floatbuttonW;floatbuttonH;f

25、loatspace=1.5;buttonW=(self.view.frame.size.width-space)2.0;buttonH-self.view.frame.size.height-space)2.0;_vdol.frame=CGReetMake(O,O,buttonW,buttonH);_vdo2Jrame-CGRectMake(buttonW+space.O.buttoW,buttonH);_vdo3.frame=CGRectMake(0,buttonH+space,buttonW,buttonH);_vdo4.frame=CGRectMake(buttonW+space,but

26、toH+space,buttoW,buttonH);for(inti=0;iDEF-SplitViewNum;i+)MyCamera*camera=cameraArrayi;if(camera.sessionState=CONNECTION_STATE_CONNECTED&(cameragetConnectionSlateOfChannel:0-CONNECTION_STATE_CONNECTED)(cameraStartShOWQScreenObjectseIf);camera.delegate2-self;UIlmageView,vdox=marrlmgVdoi;vdoxx.image=n

27、il;vdoxx.backgrondColorUIColorblackColor;UlActivityIndicatorView*activity=UIActivitylndicatorViewallocinit);activity,tag-1;activity.center=CGPointMake(vdoxx.frame.size.width2,vdo.frame.size.height2);activity.color=UIColorwhiteColor;activityStartAnimating:vdoxxaddSubview:activity;activityrelease:)ful

28、lScreenButtonl.frame-self.vdo1.frame;fullScreenButton2.frame=self.vdo2.frame;fullScreeButton3.frame=self.vdo3.frame;fIIScreenButton4.frameself.vdo4.frame;)-(VOid)CheckStatus(NSUserDefauIts,userDefaults=(NsuserDefaultsstandardUserDefauIts;if(mDummyCam=nil)mDummyCam=MyCameraaIIoc)init;)MyCameradefaull

29、Cam=mDummyCam;NSNumber,defaultChannel=NSNumbernumberWithInt:-1;if(CameraArray)CameraAnayreIease;)if(ChanneIArray)ChannelAnayreIease;CameraArray(NsMutabIeArrayaIIocinit;ChanneIAaay=UNSMUtabIeArrayaIIoCJinit;for(intIbO;icamerajist.count;i+)MyCamera,camera=(cameraIistobjectAtIncIexu;CameraArrayaddObjec

30、ticamera;Hif(camera.sessionState=CONNECTION_STATE_CONNECTED&cameragetConnectionStateOfChannel:0=CONNECTION_STATE_CONNECTED)HHCameraArrayaddbject:camera;for(NSIntegerj=cameraArray.count;j4;j+)CameraArrayaddObjeccdefauItCam;for(inti=O;iDEF_SplitViewNum;i+)(NSNumber*numSelChannel=userDefaultsobjectForK

31、ey:(NSStringstringWithFormat:ChannelMultiSetting_%d,i;if(numSelChannel)ChannelArrayaddobjectrnumSeIChanneI;else(channelArrayaddObject:defaultChannel;)for(inti=0jiDEFSpIitViewNumji+)(MyCamera*tempCamera=cameraArrayObjectAtIdex:i;f(tempCamera.ud!=nil&!(tempCamera.uidisEqualToString(S),(ull)J&(ChanneIA

32、rrayobjectAtIndex:tintValue!=-1)(SelfcameralempCamera_didChangeChannelStatus:(NSNumber*)channelArrayobjectAtlndex:iintValueChannelStatus:tempCamera.sessionState|;)-(Void)ViewDidLoad(SuperviewDidLoad);返回按钮UIButtonbackBtn=(UIButtonallocinitWithFrame:CGRectMake(O,O,60,60);(backBtnSetlmageIUllmageimageN

33、amed:-back_mainforState:UlCOntrOIStateNOrmaI);backBtnsellmage:UllmageimageNamed:back_clickedforState:UIControlStateHighlighted;backBtnaddTarget:selfaction:selector(backMyCamera)forControlEvents:UIControlEventTouchUplnside;self.viewaddSubview:backBtn;(backBtnrelease:返回按钮加拖动手势UlPanGestureRecognizer*pa

34、n=(UipanGestureRecognizeraIIocinitWithTarget:selfaction:selector(panButton:);backBtnaddGestureRecognizer:pan:panrelease);marrlmg_Vdo-QNSMutabIeArrayaNocinitWithObjects:self.vdol,self.vdo2,self.vdo3,self.vdo4,nil;(selfcheckStatus;NsNotificationCenterdefauItCenteraddbserver:selfselector:SeleCIOr(Camer

35、aStoPShoWComPleted:)name:CameraStopShowCompletedobject:nil;(NsNotificationCenterdefauItCenteraddObserver:selfselector:selector(applicationWillResignActive:)name:UIApplicationwillResignActiveNotificationObjectznil;NSNotificationCeterdefaultCenteraddObserverrsefSeleCtOr:SeleCtOr(applicationDidBeComeAC

36、tiVe:)name:lllApplicationDidBeTOmeActiveNotificationObjectzniQ;-(Void)ViewDidUnloacI(CameraArraynil;(NsNotificationCenterdefauItCenterremoveObserver:selfforKeyPath:UIApplicationwillResignActiveNotification);NsNotificationCenterdefauItCenterremoveobserver:SeIfforKeyPath:UlAPPliCaIionDidBeCOmeACIiVeN。

37、IifiCaIion;CVPiXelBUfferReIeaSe(mPixe旧Uffer);selfsetVdo1:nil;(selfsetVdo2:nil;selfsetVdo3:nil;selfsetVdo4:nil;(SuperviewDidUnIoad;-(VOie)VieWWillDiSaPPear:(BOe)L)animated(SuperviewwilIDisappearianimaled;for(MyCameracameraicameraArray)(camera.deiegate2=nil;(UlApplicationsharedAppIicationSetStatUSBarH

38、iddenrfalse;HAppDeIegate*appDelegale-(AppDeIegate,)UIApplicationSharedAppIicalion.delegate;HappDelegate.allowRotation=O;self.navigatioController.navigatioBar.hiddenNO;(NsNotificationCenterdefauItCenterremoveObserver:selfname:kApplicationDidEnterBackgroundObjectznil;NsNotificationCenterdefauItCenterr

39、emoveObSerVer:SeIfname:kAppliCationWillEnIerForegroUndobject:nil;ImTimerstartshowRevokeinvaIidate;mTimerStartShowRevoke=nil;Ullmage*navigationbarBGUIImageimageNamed:title_bk;(self.navigationController.navigationBarsetBackgroundlmage:navigationbarBGforBarMetrics:UIBarMetricsDefault;SelLnavigationItem

40、setPromptznjq;*pragmamark-ApplicationsDocumentsdirectory-(NSURL*)applicatioDocumentsDirectoryreturn(NSFiIeManagerdefauItManagerURLsForDirectory:NSDocumentDirectoryinDomains:NSUSerDOmainMaSkIastObjecU;)#Pragmamark-UlAppIicalionDelegate-(void)applicationWillResignActive:(NSNotification*)notification(f

41、or(intlO;iDEF_SplitViewNum;i+)MyCamera*testCamera=(CameraArrayobjectAtIndexzi;if(testCamera.idI=nil&!testCamera.uidisEqualToString:(null)NSNumber,chNm-ChanneIArrayobjectAtIndex:1;intch=chNmitVale;testCameraStopShowblock:ch;testCameraStopSoundToDevice:ch;testCameraSlopsoundToPhonexh:)-(void)applicati

42、onDidBecomeActive:(NSNotification)notification(for(inti=O;iDEF_SplitViewNum;i+)MyCamera*testCamra=CameraArrayobjectAtIndexj;if(testCamera.uid!=nil&!(testCamera.uidisEqualToString:(S)(null)NSNumber*chNum=ChanneIArrayobjectAtIndex:1;intch=(chNumintValue;if(lisGoPlayEvent)testCameraStartShowxhScreenObj

43、ectseIf;if(SeIectedAudioMode=AUDIO_MODE_MICROPHONE)testCameraStartSoundToDevicexh;if(SeIectedAudioMode=AUDlO_MC)DESPEAKER)testCamerastartSoundToPhonexh;)更新画面-(VOid)UpdateTOSCreen2:(NSArTay*)arrs(autoreleasepool(Cllmage*cilmage=arrsObjectAtIndex:0;NSString*uid=arrsObjectAtIndexd;NSNumber,channel-arrs

44、ObjeCIAUndeX:2;UllmageHmg=(UllmageimageWithCIImagexiImageSCale:UUISCreenrnainSereenscaleOrientationzuiImageOrientationUp;for(inti=O;iDEF_SplitViewNum;i+)(MyCamera*cameraldx-CameraArrayobjectAtIndex:i;NSNumber*channelld=ChanneIArrayobjectAtIndexj;if(Cameraldx-UidisEqualToStringiuid&channelldintValue=channelintValue)(UIImageView,vdoXX=(marrlmg_VdoobjectAtlndex:i;if(vdoXX)vdoXX.image=img;UlActivityIndicatorView*activity(vdoVieWWiIhTag:1:/停止并移除转圈if(activity)(activityStopAnimating;activityremoveFromSup

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号