91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

簡單的播放界面

發布時間:2020-07-17 12:46:20 來源:網絡 閱讀:296 作者:hmymy 欄目:開發技術

//

//  MoviePlayerView.m

//  Project1--Movie

//

//  Created by imac on 15/9/4.

//  Copyright (c) 2015年 Hong. All rights reserved.

//


#import "MoviePlayerView.h"

#import "UIView+ViewController.h"


@implementation MoviePlayerView


- (void)awakeFromNib{

    //[super awakeFromNib];

    _moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:nil];

    

    //播放界面

    _moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

    //關閉子視圖的自適應

   // _moviePlayer.backgroundView.autoresizesSubviews = NO;

    

    _moviePlayer.view.frame = self.bgView.bounds;

    _moviePlayer.controlStyle = MPMovieControlStyleNone;

    [_moviePlayer play];

    [self.bgView insertSubview:_moviePlayer.view atIndex:0];

    

    

//    //創建音量滑動條

//    _volumnSlider = [[MPVolumeView alloc]initWithFrame:CGRectMake(-75.f, 150.f, 160.f, 30.f)];

//    //!!MPVolumnView只有在真機才顯示

//    _volumnSlider.transform = CGAffineTransformMakeRotation(M_PI_2);

//    _volumnSlider.layer.anchorPoint = CGPointMake(0, 0);

//

//    [self.volumnView addSubview:_volumnSlider];

    

    //自定義滑動條

    _volumeSlider = [[UISlider alloc]initWithFrame:CGRectMake(-35.f, 50.f, 110.f, 30.f)];

    _volumeSlider.transform = CGAffineTransformMakeRotation(-M_PI_2);

    _volumeSlider.maximumValue = 10;

    _volumeSlider.minimumValue = 0;

    _volumeSlider.value = 0;


    //音量條的滑塊樣式

    [_volumeSlider setThumbImage:[UIImage p_w_picpathNamed:@"point"] forState:UIControlStateNormal];

    [_volumeView addSubview:_volumeSlider];

    [_volumeSlider addTarget:self action:@selector(volumeChange:) forControlEvents:UIControlEventValueChanged];

    

    //進度條上滑塊樣式

    [_processSlider setThumbImage:[UIImage p_w_picpathNamed:@"progress_blue_bar@2x"] forState:UIControlStateNormal];

    [_processSlider setThumbImage:[UIImage p_w_picpathNamed:@"point"] forState:UIControlStateHighlighted];

    

    //添加通知

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(duration) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];


    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createProcessTimer) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:nil];

    

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];


    //如果沒有URl就播放本地視頻

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"];

    _moviePlayer.contentURL = [NSURL fileURLWithPath:filePath];

    [_moviePlayer play];

    

    //縮放按鈕

    [_zoomBtn setImage:[UIImage p_w_picpathNamed:@"zoomin"] forState:UIControlStateNormal];

    [_zoomBtn setImage:[UIImage p_w_picpathNamed:@"zoomout"] forState:UIControlStateSelected];


    //鎖定按鈕

    [_lockBtn setTitle:@"Lock" forState:UIControlStateNormal];

    [_lockBtn setTitle:@"Unlock" forState:UIControlStateSelected];

    

    _leftTimeLabel.text = @"00:00:00";

}

#pragma mark--layoutSubviews

- (void)layoutSubviews{

    

    //獲取屏幕方向

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

    

    if (orientation == UIInterfaceOrientationPortrait) {

        self.bgView.size = CGSizeMake(kWidth, 250.f);

        self.frame = self.bgView.bounds;

    }else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){

        if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {

            self.bgView.size = CGSizeMake(kWidth, kHeight);


        }else{

            self.bgView.size = CGSizeMake(kHeight, kHeight);


        }

        self.frame = self.bgView.bounds;

    }else{

        NSLog(@"test");

    }

    

    

}

#pragma mark--Notification

- (void)duration{

    //視頻時長

    _processSlider.maximumValue = _moviePlayer.duration;

    _rightTimeLabel.text = [self calculateTime:_moviePlayer.duration];

    

}

- (void)createProcessTimer{

    _processTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(setProcess:) userInfo:nil repeats:YES];

}


- (void)movieFinish{

    [_processTimer invalidate];

    _processTimer = nil;

}

- (void)volumeChange:(UISlider *)slider{

    

    //[MPMusicPlayerController applicationMusicPlayer].volume = slider.value;

    

    

}


//設置進度

- (void)setProcess:(NSTimer *)timer{

    _second++;

    self.leftTimeLabel.text = [self calculateTime:_second];

    

    [_processSlider setValue:_second animated:YES];

}


- (NSString *)calculateTime:(NSTimeInterval)time{

    //小時

    int h = time / 3600;

    int retain = (int)time % 3600;

    

    //分鐘

    int m = retain / 60;

    //秒

    int s = retain % 60;

    

    return [NSString stringWithFormat:@"%02d:%02d:%02d",h,m,s];

}

//- (void)setUrl:(NSString *)url{

//    _url = url;

//    

//    if (url.length > 0) {

//        _moviePlayer.contentURL = [NSURL URLWithString:_url];

//        _moviePlayer.contentURL = [NSURL URLWithString:url];

//        [_moviePlayer play];

//

//    }else{

//        //如果沒有URl就播放本地視頻

//        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"];

//        _moviePlayer.contentURL = [NSURL fileURLWithPath:filePath];

//        [_moviePlayer play];

//    }

//}


#pragma mark-Touch Method

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    self.upView.hidden = !self.upView.hidden;

    self.volumeView.hidden = !self.volumeView.hidden;

    self.bottomView.hidden = !self.bottomView.hidden;

}


- (IBAction)lockClick:(UIButton *)sender {

    sender.selected = !sender.selected;

}

- (IBAction)playClick:(UIButton *)sender {

    [_moviePlayer pause];

    sender.selected = !sender.selected;

    if (sender.selected) {

        [sender setImage:[UIImage p_w_picpathNamed:@"play"] forState:UIControlStateNormal];

        [_moviePlayer pause];

        [_processTimer invalidate];

        _processTimer = nil;

    }else{

        [sender setImage:[UIImage p_w_picpathNamed:@"pause"] forState:UIControlStateNormal];

        [_moviePlayer play];

        [self createProcessTimer];

    }

}


//進度條滑動觸發事件

- (IBAction)processChange:(UISlider *)sender {

    self.leftTimeLabel.text = [self calculateTime:sender.value];

    //調整播放進度

    [_moviePlayer setCurrentPlaybackTime:sender.value];

}

- (IBAction)zoomClick:(UIButton *)sender {

    sender.selected = !sender.selected;

    if (sender.selected) {

//        self.bgView.transform = CGAffineTransformMakeRotation(-M_PI_2);

        //self.bgView.origin = CGPointMake(0 , 300);

        //self.bgView.transform = CGAffineTransformMakeScale(kHeight/self.bgView.size.width, kWidth/self.bgView.size.height);

        //self.bgView.frame =[UIScreen mainScreen].bounds;


//        self.bgView.transform = CGAffineTransformMakeTranslation(0, (kHeight-_moviePlayer.view.size.height)/2);

//        self.viewController.view.backgroundColor = [UIColor blackColor];

    }else{

//        self.bgView.transform = CGAffineTransformMakeTranslation(0, 0);

//        self.viewController.view.backgroundColor = [UIColor whiteColor];

    }

}

- (IBAction)columeClick:(UIButton *)sender {

    sender.selected = !sender.selected;

    if (sender.selected) {

        [sender setImage:[UIImage p_w_picpathNamed:@"volume_mute"] forState:UIControlStateNormal];

        _volumeSlider.value = 0;

        

    }else{

        [sender setImage:[UIImage p_w_picpathNamed:@"volume.png"] forState:UIControlStateNormal];

    }

}



@end


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

浦北县| 庆安县| 邵东县| 花莲市| 西畴县| 芒康县| 隆尧县| 龙门县| 太原市| 商城县| 拜泉县| 霍林郭勒市| 曲阳县| 北票市| 洛扎县| 商城县| 安达市| 吴江市| 商都县| 阿克陶县| 巴中市| 方城县| 彩票| 洛宁县| 宁阳县| 汝城县| 白玉县| 和田市| 府谷县| 从江县| 临桂县| 嘉禾县| 奉化市| 甘孜| 云安县| 青神县| 蓬溪县| 仙居县| 固阳县| 佛冈县| 五原县|