MPMoviePlayerController …
2013-08-19 18:22
281 查看
原文地址:MPMoviePlayerController 网络视频加载作者:huifeng3213Iphone中已经自定义好了视频播放类MPMoviePlayerController,我们只需调用既可,我自己封装好了一个视频播放类,下面就直接给大家上代码吧。
#import <UIKit/UIKit.h>
#import
<MediaPlayer/MediaPlayer.h>
//导入视频播放库
@interface CustomMoviePlayerViewController : UIViewController
{
MPMoviePlayerController *mp;
NSURL
*movieURL;
//视频地址
UIActivityIndicatorView
*loadingAni;
//加载动画
UILabel
*label;
//加载提醒
}
@property (nonatomic,retain) NSURL *movieURL;
//准备播放
- (void)readyPlayer;
@end
#import "CustomMoviePlayerViewController.h"
#pragma mark -
#pragma mark Compiler Directives & Static
Variables
@implementation CustomMoviePlayerViewController
@synthesize movieURL;
- (void)viewDidLoad
{
[super
viewDidLoad];
loadingAni =
[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(140, 150,
37, 37)];
loadingAni.activityIndicatorViewStyle =
UIActivityIndicatorViewStyleWhiteLarge;
[self.view
addSubview:loadingAni];
label =
[[UILabel alloc] initWithFrame:CGRectMake(130, 190, 80, 40)];
label.text =
@"加载中...";
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[[self view]
setBackgroundColor:[UIColor blackColor]];
[loadingAni
startAnimating];
[self.view
addSubview:label];
}
- (void)
moviePlayerLoadStateChanged:(NSNotification*)notification
{
[loadingAni
stopAnimating];
[label
removeFromSuperview];
// Unless
state is unknown, start playback
if ([mp
loadState] != MPMovieLoadStateUnknown)
{
// Remove
observer
[[NSNotificationCenter
defaultCenter] removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
// When
tapping movie, status bar will appear, it shows up
// in
portrait mode by default. Set orientation to landscape
//设置横屏
[[UIApplication sharedApplication]
setStatusBarOrientation:UIInterfaceOrientationLa
#import <UIKit/UIKit.h>
#import
<MediaPlayer/MediaPlayer.h>
//导入视频播放库
@interface CustomMoviePlayerViewController : UIViewController
{
MPMoviePlayerController *mp;
NSURL
*movieURL;
//视频地址
UIActivityIndicatorView
*loadingAni;
//加载动画
UILabel
*label;
//加载提醒
}
@property (nonatomic,retain) NSURL *movieURL;
//准备播放
- (void)readyPlayer;
@end
#import "CustomMoviePlayerViewController.h"
#pragma mark -
#pragma mark Compiler Directives & Static
Variables
@implementation CustomMoviePlayerViewController
@synthesize movieURL;
- (void)viewDidLoad
{
[super
viewDidLoad];
loadingAni =
[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(140, 150,
37, 37)];
loadingAni.activityIndicatorViewStyle =
UIActivityIndicatorViewStyleWhiteLarge;
[self.view
addSubview:loadingAni];
label =
[[UILabel alloc] initWithFrame:CGRectMake(130, 190, 80, 40)];
label.text =
@"加载中...";
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[[self view]
setBackgroundColor:[UIColor blackColor]];
[loadingAni
startAnimating];
[self.view
addSubview:label];
}
- (void)
moviePlayerLoadStateChanged:(NSNotification*)notification
{
[loadingAni
stopAnimating];
[label
removeFromSuperview];
// Unless
state is unknown, start playback
if ([mp
loadState] != MPMovieLoadStateUnknown)
{
// Remove
observer
[[NSNotificationCenter
defaultCenter] removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
// When
tapping movie, status bar will appear, it shows up
// in
portrait mode by default. Set orientation to landscape
//设置横屏
[[UIApplication sharedApplication]
setStatusBarOrientation:UIInterfaceOrientationLa
相关文章推荐
- iOS MPMoviePlayerController(已废弃)入门使用(模仿keep未登录)&广告动画开场效果
- Xcode 4.2 "_OBJC_CLASS_$_MPMoviePlayerViewController 编译不通过
- MPMoviePlayerViewController 视频播放黑屏
- iOS7 MPMoviePlayerViewController 横屏显示
- ios学习--MPMoviePlayerController播放视频的方法
- MX Player Pro v1.…
- 用MPMoviePlayerController播放视频的方法
- MPMoviePlayerController 缓存在线视频
- MPMoviePlayerController 电影播放器
- MPMoviePlayerController 自定义过程中的声音问题
- Dismissing MPMoviePlayerViewController the right way
- MPMoviePlayerController的使用
- iphone ios MPMoviePlayerController在ios 6 模拟器中无法播放
- MPMoviePlayerController
- SDK 4.0 MPMoviePlayerController 遇到无法播放视频问题
- MPMoviePlayerController的按钮“done”显示为“完成”
- MPMoviePlayerController
- IOS MPMoviePlayerViewController视频播放(MediaPlayer)
- 【iOS开发】解决“点击MPMoviePlayerController播放视频时,出现一个黑屏闪屏问题”
- ios学习--MPMoviePlayerViewController和MPMoviePlayerController