首页 > 其他 > 详细

简单媒体播放器

时间:2015-06-12 23:34:58      阅读:252      评论:0      收藏:0      [点我收藏+]

//

//  ViewController.m

//  简单媒体播放器

//

//  Created by 殷婷婷 on 15-6-12.

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

//

 

#import "ViewController.h"

#import <MediaPlayer/MediaPlayer.h>

@interface ViewController ()

 

@property(nonatomic,strong)MPMoviePlayerController *player;

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

    NSString *path = [[NSBundle mainBundle]pathForResource:@"1.mp4" ofType:nil];

    self.player = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:path]];

    self.player.view.frame = CGRectMake(0, 0, 320, 360);

    

    

}

 

 

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

    

    [self.view addSubview:self.player.view];

    

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(didFinishPlay) name:MPMoviePlayerPlaybackDidFinishNotification object:self.player];

    [self.player play];

}

 

- (void)didFinishPlay{

    

    [self.player.view removeFromSuperview];

    [[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:self.player];

}

@end

 

简单媒体播放器

原文:http://www.cnblogs.com/yintingting/p/4572676.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!