版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
PAGEPAGE1SDEASYCAM手機APP軟件(1.0.8)#import"MKHorizMenu.h"#definekButtonBaseTag10000#definekLeftOffset5@implementationMKHorizMenu@synthesizetitles=_titles;@synthesizeselectedImage=_selectedImage;@synthesizeitemSelectedDelegate;@synthesizedataSource;@synthesizeitemCount=_itemCount;-(void)awakeFromNib{
self.bounces=YES;
self.scrollEnabled=YES;
self.alwaysBounceHorizontal=YES;
self.alwaysBounceVertical=NO;
self.showsHorizontalScrollIndicator=NO;
self.showsVerticalScrollIndicator=NO;
[selfreloadData];}-(void)reloadSoundBtn{
}
-(void)reloadData{
NSArray*viewsToRemove=[selfsubviews]; for(UIView*vinviewsToRemove){ [vremoveFromSuperview]; }
self.itemCount=[dataSourcenumberOfItemsForMenu:self];
self.backgroundColor=[dataSourcebackgroundColorForMenu:self];
//self.selectedImage=[dataSourceselectedItemImageForMenu:self];
UIFont*buttonFont=[UIFontboldSystemFontOfSize:15];
intbuttonPadding=5;
inttag=kButtonBaseTag;
intxPos=kLeftOffset;
CGFloatbtnTotalWidth=0.0f;
for(inti=0;i<self.itemCount;i++){
UIImage*bgImg=[UIImageimageNamed:[dataSourcehorizMenu:selftitleForItemAtIndex:i]];
btnTotalWidth+=bgImg.size.width;
if(i==3){
NSLog(@"OK");
}
}
//計算左右變距
CGFloattotalLen=(self.itemCount-1)*buttonPadding+btnTotalWidth;
CGFloatleftX=(self.superview.frame.size.width-totalLen)/2;
if(leftX<0)leftX=xPos;
xPos=leftX;
for(inti=0;i<self.itemCount;i++)
{
NSString*title=@"";
UIButton*customButton=[UIButtonbuttonWithType:UIButtonTypeCustom];
[customButtonsetTitle:titleforState:UIControlStateNormal];
customButton.titleLabel.font=buttonFont;
UIImage*bgImg=[UIImageimageNamed:[dataSourcehorizMenu:selftitleForItemAtIndex:i]];
[customButtonsetBackgroundImage:bgImgforState:UIControlStateNormal];
[customButtonsetBackgroundImage:[UIImageimageNamed:[dataSourceselectedItemImageForMenu:selfitemAtIndex:i]]forState:UIControlStateSelected];
[customButtonsetBackgroundImage:[UIImageimageNamed:[dataSourceselectedItemImageForMenu:selfitemAtIndex:i]]forState:UIControlStateHighlighted];
customButton.tag=tag++;
[customButtonaddTarget:selfaction:@selector(buttonTapped:)forControlEvents:UIControlEventTouchUpInside];
[customButtonaddTarget:selfaction:@selector(buttonTouchDown:)forControlEvents:UIControlEventTouchDown];
customButton.frame=CGRectMake(xPos,3,bgImg.size.width,38);
xPos+=bgImg.size.width;
if(i+1<self.itemCount){
xPos+=buttonPadding;
}
[selfaddSubview:customButton];
}
xPos+=leftX;
if(xPos<self.frame.size.width)xPos=self.frame.size.width;
self.contentSize=CGSizeMake(xPos,self.frame.size.height);
[selflayoutSubviews];
}#import<IOTCamera/GLog.h>#import<IOTCamera/GLogZone.h>#import"CameraMultiLiveViewController.h"#import<IOTCamera/AVFRAMEINFO.h>#import<IOTCamera/ImageBuffInfo.h>#import<sys/time.h>#import<AVFoundation/AVFoundation.h>#import"AppDelegate.h"#import"MyNavViewController.h"#import"UIDevice+Device.h"#defineDEF_WAIT4STOPSHOW_TIME 250#defineDEF_SplitViewNum 4#defineDEF_ReTryConnectInterval25*1000#defineDEF_ReTryTimes 10@interfaceCameraMultiLiveViewController(){ MyCamera*mDummyCam; NSMutableArray*marrImg_Vdo; intmnReTryTimesArray[DEF_SplitViewNum]; unsignedintmnLastReTryTickArray[DEF_SplitViewNum];
}@end@implementationCameraMultiLiveViewController@synthesizebStopShowCompletedLock;@synthesizeselectedAudioMode;@synthesizecamNeedReconnect;@synthesizeselectCameraArray;@synthesizecameraArray;@synthesizechannelArray;#pragmamarkMethods-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
returnUIInterfaceOrientationLandscapeLeft;}-(CGRect)zoomRectForScrollView:(UIScrollView*)_scrollViewwithScale:(CGFloat)scalewithCenter:(CGPoint)center{
CGRectzoomRect;
//Thezoomrectisinthecontentview'scoordinates.
//Atazoomscaleof1.0,itwouldbethesizeofthe
//imageScrollView'sbounds.
//Asthezoomscaledecreases,somorecontentisvisible,
//thesizeoftherectgrows.
zoomRect.size.height=_scrollView.frame.size.height/scale;
zoomRect.size.width
=_scrollView.frame.size.width
/scale;
//chooseanoriginsoastogettherightcenter.
zoomRect.origin.x=center.x-(zoomRect.size.width
/2.0);
zoomRect.origin.y=center.y-(zoomRect.size.height/2.0);
returnzoomRect;}-(UIImage*)getUIImage:(char*)buffWidth:(NSInteger)widthHeight:(NSInteger)height{
CGDataProviderRefprovider=CGDataProviderCreateWithData(NULL,buff,width*height*3,NULL);
CGColorSpaceRefcolorSpace=CGColorSpaceCreateDeviceRGB();
CGImageRefimgRef=CGImageCreate(width,height,8,24,width*3,colorSpace,kCGBitmapByteOrderDefault,provider,NULL,true,
kCGRenderingIntentDefault);
UIImage*img=[UIImageimageWithCGImage:imgRef];
if(imgRef!=nil){
CGImageRelease(imgRef);
imgRef=nil;
}
if(colorSpace!=nil){
CGColorSpaceRelease(colorSpace);
colorSpace=nil;
}
if(provider!=nil){
CGDataProviderRelease(provider);
provider=nil;
}
return[[imgcopy]autorelease];}-(void)camStopShow:(int)aIgnoreIdx{
isCamStopShow=YES;
for(inti=0;i<DEF_SplitViewNum;i++){ if(i==aIgnoreIdx){ continue; }
MyCamera*testCamera=[cameraArrayobjectAtIndex:i];
if(testCamera.uid!=nil&&![testCamera.uidisEqualToString:@"(null)"]){
NSNumber*tempChannel=[channelArrayobjectAtIndex:i];
if(testCamera.sessionState==CONNECTION_STATE_CONNECTED&&[testCameragetConnectionStateOfChannel:0]==CONNECTION_STATE_CONNECTED){
testCamera.isShowInMultiView=NO;
[testCamerastopShow:[tempChannelintValue]];
}
}
}}-(void)reStartShow{
isCamStopShow=NO;
for(inti=0;i<DEF_SplitViewNum;i++){
MyCamera*tempCamera=[cameraArrayobjectAtIndex:i];
if(tempCamera.uid!=nil&&![tempCamera.uidisEqualToString:@"(null)"]){
NSNumber*tempChannel=[channelArrayobjectAtIndex:i];
if(tempCamera.sessionState==CONNECTION_STATE_CONNECTED&&[tempCameragetConnectionStateOfChannel:0]==CONNECTION_STATE_CONNECTED){
if(!isGoPlayEvent){
tempCamera.isShowInMultiView=YES;
[tempCamerastartShow:[tempChannelintegerValue]ScreenObject:self];
}
}
}
}}-(void)reConnectAndShow{
for(inti=0;i<DEF_SplitViewNum;i++){
MyCamera*tempCamera=[cameraArrayobjectAtIndex:i];
if(tempCamera.uid!=nil&&![tempCamera.uidisEqualToString:@"(null)"]){
[channelArrayobjectAtIndex:i];
[selfdisconnectCamera:tempCamera.uid]; [tempCameradisconnect];
[tempCameraconnect:tempCamera.uid];
[tempCamerastart:0];
if(!isGoPlayEvent){
tempCamera.isShowInMultiView=YES;
//[tempCamerastartShow:0ScreenObject:self];
}
tempCamera.delegate2=self;
}
}}-(void)disconnectCamera:(NSString*)strUID{ for(inti=0;i<DEF_SplitViewNum;i++){ MyCamera*cam=[cameraArrayobjectAtIndex:i]; NSNumber*numChannel=[channelArrayobjectAtIndex:i]; if([cam.uidisEqualToString:strUID]){ [camstop:[numChannelintValue]]; } }}//進入播放界面-(IBAction)goLiveView:(id)sender{ intnIdx=(int)[(UIView*)sendertag]; MyCamera*tempCamera=[cameraArrayobjectAtIndex:nIdx]; if(tempCamera.uid!=nil&&![tempCamera.uidisEqualToString:@"(null)"]&&(tempCamera.sessionState==CONNECTION_STATE_CONNECTED&&[tempCameragetConnectionStateOfChannel:0]==CONNECTION_STATE_CONNECTED))
{ intchannel=(int)[[channelArrayobjectAtIndex:nIdx]intValue]; [selfcamStopShow:nIdx]; CameraLiveViewController*controller=[[CameraLiveViewControlleralloc]initWithNibName:@"CameraLiveView"bundle:nil]; controller.camera=tempCamera; controller.viewTag=[NSNumbernumberWithInt:(int)[(UIView*)sendertag]]; controller.delegate=self; controller.selectedChannel=channel; UINavigationController*customNavController=[[MyNavViewControlleralloc]init]; [selfpresentViewController:customNavControlleranimated:YEScompletion:nil]; [customNavControllerpushViewController:controlleranimated:YES]; [controllerrelease]; [customNavControllerrelease]; }}//返回攝像機列表界面-(void)backMyCamera{
AppDelegate*appDelegate=(AppDelegate*)[UIApplicationsharedApplication].delegate;
appDelegate.allowRotation=0;
for(inti=0;i<DEF_SplitViewNum;i++)
{
MyCamera*cameraIdx=[cameraArrayobjectAtIndex:i];
[cameraIdxstopShow:0];
}
[selfdismissViewControllerAnimated:YEScompletion:nil];}#pragmamark-Viewlifecycle-(void)dealloc{
[_vdo1release];
[_vdo2release];
[_vdo3release];
[_vdo4release];
[marrImg_Vdorelease]; [mDummyCamrelease]; [superdealloc];}-(void)viewWillLayoutSubviews{
[superviewWillLayoutSubviews];
floatbuttonW;
floatbuttonH;
floatspace=1.5;
buttonW=(self.view.frame.size.width-space)/2.0;
buttonH=(self.view.frame.size.height-space)/2.0;
_vdo1.frame=CGRectMake(0,0,buttonW,buttonH);
_vdo2.frame=CGRectMake(buttonW+space,0,buttonW,buttonH);
_vdo3.frame=CGRectMake(0,buttonH+space,buttonW,buttonH);
_vdo4.frame=CGRectMake(buttonW+space,buttonH+space,buttonW,buttonH);
for(inti=0;i<DEF_SplitViewNum;i++)
{
MyCamera*camera=cameraArray[i];
if(camera.sessionState==CONNECTION_STATE_CONNECTED&&[cameragetConnectionStateOfChannel:0]==CONNECTION_STATE_CONNECTED)
{
[camerastartShow:0ScreenObject:self];
camera.delegate2=self;
UIImageView*vdoxx=marrImg_Vdo[i];
vdoxx.image=nil;
vdoxx.backgroundColor=[UIColorblackColor];
UIActivityIndicatorView*activity=[[UIActivityIndicatorViewalloc]init];
activity.tag=1;
activity.center=CGPointMake(vdoxx.frame.size.width/2,vdoxx.frame.size.height/2);
activity.color=[UIColorwhiteColor];
[activitystartAnimating];
[vdoxxaddSubview:activity];
[activityrelease];
}
}
fullScreenButton1.frame=self.vdo1.frame;
fullScreenButton2.frame=self.vdo2.frame;
fullScreenButton3.frame=self.vdo3.frame;
fullScreenButton4.frame=self.vdo4.frame;}-(void)checkStatus{ NSUserDefaults*userDefaults=[NSUserDefaultsstandardUserDefaults]; if(mDummyCam==nil){ mDummyCam=[[MyCameraalloc]init]; } MyCamera*defaultCam=mDummyCam;
NSNumber*defaultChannel=[NSNumbernumberWithInt:-1]; if(cameraArray){ [cameraArrayrelease]; } if(channelArray){ [channelArrayrelease]; }
cameraArray=[[NSMutableArrayalloc]init];
channelArray=[[NSMutableArrayalloc]init];
for(inti=0;i<camera_list.count;i++)
{
MyCamera*camera=[camera_listobjectAtIndex:i];
[cameraArrayaddObject:camera];//
if(camera.sessionState==CONNECTION_STATE_CONNECTED&&[cameragetConnectionStateOfChannel:0]==CONNECTION_STATE_CONNECTED)//
{//
[cameraArrayaddObject:camera];//
}
}
for(NSIntegerj=cameraArray.count;j<4;j++)
{
[cameraArrayaddObject:defaultCam];
}
for(inti=0;i<DEF_SplitViewNum;i++)
{ NSNumber*numSelChannel=[userDefaultsobjectForKey:[NSStringstringWithFormat:@"ChannelMultiSetting_%d",i]];
if(numSelChannel){
[channelArrayaddObject:numSelChannel];
}else{
[channelArrayaddObject:defaultChannel];
}
}
for(inti=0;i<DEF_SplitViewNum;i++)
{
MyCamera*tempCamera=[cameraArrayobjectAtIndex:i];
if(tempCamera.uid!=nil&&![tempCamera.uidisEqualToString:@"(null)"]&&[[channelArrayobjectAtIndex:i]intValue]!=-1)
{ [selfcamera:tempCamera_didChangeChannelStatus:[(NSNumber*)[channelArrayobjectAtIndex:i]intValue]ChannelStatus:tempCamera.sessionState];
}
}}-(void)viewDidLoad{
[superviewDidLoad];
//返回按鈕
UIButton*backBtn=[[UIButtonalloc]initWithFrame:CGRectMake(0,0,60,60)];
[backBtnsetImage:[UIImageimageNamed:@"back_main"]forState:UIControlStateNormal];
[backBtnsetImage:[UIImageimageNamed:@"back_clicked"]forState:UIControlStateHighlighted];
[backBtnaddTarget:selfaction:@selector(backMyCamera)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:backBtn];
[backBtnrelease];
//返回按鈕加拖動手勢
UIPanGestureRecognizer*pan=[[UIPanGestureRecognizeralloc]initWithTarget:selfaction:@selector(panButton:)];
[backBtnaddGestureRecognizer:pan];
[panrelease]; marrImg_Vdo=[[NSMutableArrayalloc]initWithObjects:self.vdo1,self.vdo2,self.vdo3,self.vdo4,nil];
[selfcheckStatus];
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(cameraStopShowCompleted:)name:@"CameraStopShowCompleted"object:nil];
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}-(void)viewDidUnload{
cameraArray=nil;
[[NSNotificationCenterdefaultCenter]removeObserver:selfforKeyPath:UIApplicationWillResignActiveNotification];
[[NSNotificationCenterdefaultCenter]removeObserver:selfforKeyPath:UIApplicationDidBecomeActiveNotification];
CVPixelBufferRelease(mPixelBuffer);
[selfsetVdo1:nil];
[selfsetVdo2:nil];
[selfsetVdo3:nil];
[selfsetVdo4:nil];
[superviewDidUnload];}-(void)viewWillDisappear:(BOOL)animated{
[superviewWillDisappear:animated];
for(MyCamera*cameraincameraArray)
{
camera.delegate2=nil;
}
[[UIApplicationsharedApplication]setStatusBarHidden:false];//
AppDelegate*appDelegate=(AppDelegate*)[UIApplicationsharedApplication].delegate;//
appDelegate.allowRotation=0;
self.navigationController.navigationBar.hidden=NO;
[[NSNotificationCenterdefaultCenter]removeObserver:selfname:kApplicationDidEnterBackground
object:nil]; [[NSNotificationCenterdefaultCenter]removeObserver:selfname:kApplicationWillEnterForeground
object:nil]; [mTimerStartShowRevokeinvalidate]; mTimerStartShowRevoke=nil;
UIImage*navigationbarBG=[UIImageimageNamed:@"title_bk"];
[self.navigationController.navigationBarsetBackgroundImage:navigationbarBGforBarMetrics:UIBarMetricsDefault];
[self.navigationItemsetPrompt:nil]; }#pragmamark-Application'sDocumentsdirectory-(NSURL*)applicationDocumentsDirectory{
return[[[NSFileManagerdefaultManager]
URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask]lastObject];}#pragmamark-UIApplicationDelegate-(void)applicationWillResignActive:(NSNotification*)notification{
for(inti=0;i<DEF_SplitViewNum;i++){
MyCamera*testCamera=[cameraArrayobjectAtIndex:i];
if(testCamera.uid!=nil&&![testCamera.uidisEqualToString:@"(null)"]){
NSNumber*chNum=[channelArrayobjectAtIndex:i]; intch=[chNumintValue]; [testCamerastopShow_block:ch]; [testCamerastopSoundToDevice:ch]; [testCamerastopSoundToPhone:ch];
}
} }-(void)applicationDidBecomeActive:(NSNotification*)notification{
for(inti=0;i<DEF_SplitViewNum;i++){
MyCamera*testCamera=[cameraArrayobjectAtIndex:i];
if(testCamera.uid!=nil&&![testCamera.uidisEqualToString:@"(null)"]){
NSNumber*chNum=[channelArrayobjectAtIndex:i]; intch=[chNumintValue];
if(!isGoPlayEvent){
[testCamerastartShow:chScreenObject:self];
}
if(selectedAudioMode==AUDIO_MODE_MICROPHONE) [testCamerastartSoundToDevice:ch];
if(selectedAudioMode==AUDIO_MODE_SPEAKER) [testCamerastartSoundToPhone:ch];
}
}}//更新畫面-(void)updateToScreen2:(NSArray*)arrs{
@autoreleasepool
{
CIImage*ciImage=[arrsobjectAtIndex:0];
NSString*uid=[arrsobjectAtIndex:1];
NSNumber*channel=[arrsobjectAtIndex:2];
UIImage*img=[UIImageimageWithCIImage:ciImagescale:[[UIScreenmainScreen]scale]orientation:UIImageOrientationUp];
for(inti=0;i<DEF_SplitViewNum;i++)
{
MyCamera*cameraIdx=[cameraArrayobjectAtIndex:i];
NSNumber*channelIdx=[channelArrayobjectAtIndex:i];
if([cameraIdx.uidisEqualToString:uid]&&[channelIdxintValue]==[channelintValue]){ UIImageView*vdoXX=[marrImg_VdoobjectAtIndex:i]; if(vdoXX)
{ vdoXX.image=img;
UIActivityIndicatorView*activity=[vdoXXviewWithTag:1];
//停止并移除轉(zhuǎn)圈
if(activity)
{
[activitystopAnimating];
[activityremoveFromSuperview];
} }
}
}
}}-(void)cameraStopShowCompleted:(NSNotification*)notification{ bStopShowCompletedLock=TRUE;}-(void)didEnterBackground:(NSNotification*)notif{ if(mTimerStartShowRevoke!=nil){ [mTimerStartShowRevokeinvalidate]; mTimerStartShowRevoke=nil; } [[NSNotificationCenterdefaultCenter]removeObserver:selfname:kApplicationDidEnterBackground
object:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(didEnterForeground:)name:kApplicationWillEnterForegroundobject:nil]; for(inti=0;i<DEF_SplitViewNum;i++){ MyCamera*theCamera=[cameraArrayobjectAtIndex:i]; NSNumber*numChannel=[channelArrayobjectAtIndex:i]; if(theCamera.uid!=nil&&![theCamera.uidisEqualToString:@"(null)"]&&[numChannelintValue]>=0){ [theCamerastopShow:[numChannelintValue]]; }
} }-(void)didEnterForeground:(NSNotification*)notif{ if(mTimerStartShowRevoke){ [mTimerStartShowRevokeinvalidate]; mTimerStartShowRevoke=nil; } [[NSNotificationCenterdefaultCenter]removeObserver:selfname:kApplicationWillEnterForeground
object:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(didEnterBackground:)name:kApplicationDidEnterBackgroundobject:nil]; for(inti=0;i<DEF_SplitViewNum;i++){ MyCamera*theCamera=[cameraArrayobjectAtIndex:i]; NSNumber*numChannel=[channelArrayobjectAtIndex:i]; if(theCamera.uid!=nil&&![theCamera.uidisEqualToString:@"(null)"]&&[numChannelintValue]>=0)
{ [theCamerastartShow:[numChannelintValue]ScreenObject:self]; } }}#import"RecordFileViewController.h"#import<AVFoundation/AVFoundation.h>@interfaceRecordFileViewController()@end@implementationRecordFileViewController@synthesizecamera;-(void)setVideoArray:(NSArray*)arrayvideoPath:(NSString*)path{
videoArray=[[NSMutableArrayalloc]init];
inti;
for(i=0;i<[arraycount];i++){
NSString*urlStr=[NSStringstringWithFormat:@"%@/%@",path,[[arrayobjectAtIndex:i]stringByReplacingOccurrencesOfString:@"jpg"withString:@"mp4"]];
[videoArrayaddObject:urlStr];
}}-(IBAction)back:(id)sender{
[self.navigationControllerpopViewControllerAnimated:YES];}-(IBAction)playOrPause{
if(isPlaying){
[playAndPauseBTNsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay"]forState:UIControlStateNormal];
[playAndPauseBTNsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay_click"]forState:UIControlStateHighlighted];
[playAndPauseBTN_hsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay_h"]forState:UIControlStateNormal];
[playAndPauseBTN_hsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay_click_h"]forState:UIControlStateHighlighted];
[moviePlayerControllerpause];
isPlaying=NO;
[playerDurationTimerinvalidate];
}else{
[playAndPauseBTNsetBackgroundImage:[UIImageimageNamed:@"ceo_pause"]forState:UIControlStateNormal];
[playAndPauseBTNsetBackgroundImage:[UIImageimageNamed:@"ceo_pause_click"]forState:UIControlStateHighlighted];
[playAndPauseBTN_hsetBackgroundImage:[UIImageimageNamed:@"ceo_pause_h"]forState:UIControlStateNormal];
[playAndPauseBTN_hsetBackgroundImage:[UIImageimageNamed:@"ceo_pause_click_h"]forState:UIControlStateHighlighted];
[moviePlayerControllerplay];
isPlaying=YES;
playerDurationTimer=[NSTimerscheduledTimerWithTimeInterval:1.0target:selfselector:@selector(updateTime:)userInfo:nilrepeats:YES];
}}-(IBAction)slide{
if(isLandscape){
moviePlayerController.currentPlaybackTime=(totalMinute*60+totalSecond)*timeSlider_h.value;
}else{
moviePlayerController.currentPlaybackTime=(totalMinute*60+totalSecond)*timeSlider.value;
}
[moviePlayerControllerplay];
if(!isPlaying){
isPlaying=YES;
playerDurationTimer=[NSTimerscheduledTimerWithTimeInterval:1.0target:selfselector:@selector(updateTime:)userInfo:nilrepeats:YES];
}}-(void)updateTime:(NSTimer*)timer{
intcurrentSecond=(int)moviePlayerController.currentPlaybackTime;
intcurrentMinute=0;
if(currentSecond>=60){
intindex=currentSecond/60;
currentMinute=index;
currentSecond=currentSecond-index*60;
}
if(currentSecond>=10){
[currentTimeLabelsetText:[NSStringstringWithFormat:@"%d:%d",currentMinute,currentSecond]];
[currentTimeLabel_hsetText:[NSStringstringWithFormat:@"%d:%d",currentMinute,currentSecond]];
}else{
[currentTimeLabelsetText:[NSStringstringWithFormat:@"%d:0%d",currentMinute,currentSecond]];
[currentTimeLabel_hsetText:[NSStringstringWithFormat:@"%d:0%d",currentMinute,currentSecond]];
}
timeSlider_h.value=moviePlayerController.currentPlaybackTime/floatSec;
timeSlider.value=moviePlayerController.currentPlaybackTime/floatSec;
if(isPlayOver){
timeSlider.value=0;
timeSlider_h.value=0;
[currentTimeLabelsetText:@"0:00"];
[currentTimeLabel_hsetText:@"0:00"];
[moviePlayerControllerplay];
[moviePlayerControllerpause];
[playAndPauseBTNsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay"]forState:UIControlStateNormal];
[playAndPauseBTNsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay_click"]forState:UIControlStateHighlighted];
[playAndPauseBTN_hsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay_h"]forState:UIControlStateNormal];
[playAndPauseBTN_hsetBackgroundImage:[UIImageimageNamed:@"ceo_rcplay_click_h"]forState:UIControlStateHighlighted];
isPlaying=NO;
isPlayOver=NO;
[playerDurationTimerinvalidate];
}elseif(timeSlider.value>=1){
isPlayOver=YES;
}}-(void)setPlayer:(NSString*)urlStrindex:(int)arrayIndex_{
arrayIndex=arrayIndex_;
NSURL*movieURL=[NSURLfileURLWithPath:urlStr];
NSDictionary*opts=[NSDictionarydictionaryWithObject:[NSNumbernumberWithBool:NO]
forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset*urlAsset=[AVURLAssetURLAssetWithURL:movieURLoptions:opts];
//初始化影片
totalMinute=0;
totalSecond=0;
totalSecond=(int)urlAsset.duration.value/urlAsset.duration.timescale;//獲取影片長度(單位:秒)
floatSec=(float)urlAsset.duration.value/(float)urlAsset.duration.timescale;
if(totalSecond>=60){
intindex=totalSecond/60;
totalMinute=index;
totalSecond=totalSecond-index*60;
}
//進入播放介面
moviePlayerController=[[MPMoviePlayerControlleralloc]initWithContentURL:[NSURLfileURLWithPath:urlStr]];
[moviePlayerController.viewsetFrame:CGRectMake(0,66,self.view.frame.size.width,self.view.frame.size.width*3/4)];
[self.viewaddSubview:moviePlayerController.view];
moviePlayerController.controlStyle=MPMovieControlStyleNone;
moviePlayerController.movieSourceType=MPMovieSourceTypeFile;
moviePlayerController.shouldAutoplay=NO;
[moviePlayerControllerprepareToPlay];
scrollView.delegate=self;
scrollView.pagingEnabled=YES;
UITapGestureRecognizer*singleFingerTap=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(handleSingleTap:)]; [scrollViewaddGestureRecognizer:singleFingerTap]; [singleFingerTaprelease];
UISwipeGestureRecognizer*leftRecognizer;
leftRecognizer=[[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(handleSwipeFrom:)];
[leftRecognizersetDirection:UISwipeGestureRecognizerDirectionLeft];
[scrollViewaddGestureRecognizer:leftRecognizer];
[leftRecognizerrelease];
UISwipeGestureRecognizer*rightRecognizer;
rightRecognizer=[[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(handleSwipeFrom:)];
[rightRecognizersetDirection:UISwipeGestureRecognizerDirectionRight];
[scrollViewaddGestureRecognizer:rightRecognizer];
[rightRecognizerrelease];
[self.viewbringSubviewToFront:scrollView];}-(void)reSetPlayer{
NSURL*movieURL=[NSURLfileURLWithPath:[videoArrayobjectAtIndex:arrayIndex]];
NSDictionary*opts=[NSDictionarydictionaryWithObject:[NSNumbernumberWithBool:NO]
forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset*urlAsset=[AVURLAssetURLAssetWithURL:movieURLoptions:opts];
//初始化影片
totalMinute=0;
totalSecond=0;
totalSecond=(int)urlAsset.duration.value/urlAsset.duration.timescale;//獲取影片長度(單位:秒)
floatSec=(float)urlAsset.duration.value/(float)urlAsset.duration.timescale;
if(totalSecond>=60){
intindex=totalSecond/60;
totalMinute=index;
totalSecond=totalSecond-index*60;
}
if(isPlaying){
[moviePlayerControllerpause];
}
if(totalSecond>=10){
[totalTimeLabelsetText:[NSStringstringWithFormat:@"%d:%d",totalMinute,totalSecond]];
[totalTimeLabel_hsetText:[NSStrings
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 租賃施工機械合同范本
- 2024年智慧城市大數(shù)據(jù)平臺合同
- 2025年建筑工程工料分包合同
- 2025版雙方合作合同保證書(金融資產(chǎn)證券化合作版)3篇
- 買房協(xié)議書和合同有何區(qū)別
- 2025版小漁船買賣合同含船舶性能評估及交易保障3篇
- 2025年度跨境電商店鋪租賃及物流服務合同
- 2025年全球及中國真空拾取筆行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025年度個人與公司間信用借款合同規(guī)范3篇
- 二零二五年度采石場安全生產(chǎn)監(jiān)管服務合同3篇
- 衛(wèi)生服務個人基本信息表
- 醫(yī)學脂質(zhì)的構(gòu)成功能及分析專題課件
- 高技能人才培養(yǎng)的策略創(chuàng)新與實踐路徑
- 廣東省湛江市廉江市2023-2024學年八年級上學期期末考試數(shù)學試卷(含答案)
- 2024年湖北省知名中小學教聯(lián)體聯(lián)盟中考語文一模試卷
- 安徽省蕪湖市2023-2024學年高一上學期期末考試 生物 含解析
- 交叉口同向可變車道動態(tài)控制與信號配時優(yōu)化研究
- 燃氣行業(yè)有限空間作業(yè)安全管理制度
- 數(shù)列練習題(含答案)基礎知識點
- 人教版(2024新版)七年級上冊英語期中+期末學業(yè)質(zhì)量測試卷 2套(含答案)
- 安華農(nóng)業(yè)保險股份有限公司北京市地方財政生豬價格指數(shù)保險條款(風險敏感型)
評論
0/150
提交評論