博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iphone 制作在线播放器
阅读量:7093 次
发布时间:2019-06-28

本文共 1320 字,大约阅读时间需要 4 分钟。

摘自:

 

Iphone中已经自定义好了视频播放类MPMoviePlayerController,我们只需调用既可,下面详细介绍一下调用手机播放器的例子:

首先创建一个视图工程PlayMoveViewDemo,然后声明其类型:

#import <UIKit/UIKit.h>

 

@interface PlayMoveViewDemoViewController : UIViewController {

 

IBOutlet UIButton *button;

 

}

 

@property (nonatomic,retain)UIButton *button;

 

-(IBAction) pressedbutton:(id)sender;

 

@end

 

然后利用Interface builder创建一个按钮,并且把相应的声明和按钮相链接。

接下来需要引入相应的播放器实现,引入方法:

双击红色边框:

201008121054.jpg

添加相应的类:

201008121056.jpg

点击完成即可。

添加播放代码:

#import “PlayMoveViewDemoViewController.h”

#import “MediaPlayer/MediaPlayer.h”

 

@implementation PlayMoveViewDemoViewController

 

@synthesize button;

 

-(IBAction) pressedbutton:(id)sender

 

{

 

NSLog(@”按到我了“);

 

[self playVideo];

 

}

 

- (void)playVideo

{

MPMoviePlayerController *moviePlayer;

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURLURLWithString:@"http://dev.mopietek.net:8080/mp4/320480flv.3gp"]];

moviePlayer.movieControlMode = MPMovieControlModeDefault;

[moviePlayer play];

//[path release];

NSLog(@”play~”);

}

 

- (void)didReceiveMemoryWarning {

// Releases the view if it doesn’t have a superview.

[super didReceiveMemoryWarning];

 

// Release any cached data, images, etc that aren’t in use.

}

 

- (void)viewDidUnload {

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

}

 

 

- (void)dealloc {

[button release];

[super dealloc];

}

 

@end

编辑运行既可:

201008121059.jpg

点击play:

201008121059.jpg

播放器就完成了。

 

转载地址:http://pfiql.baihongyu.com/

你可能感兴趣的文章
[nio]dawn的基本概念
查看>>
【数据库摘要】6_Sql_Inner_Join
查看>>
交叉熵代价函数(损失函数)及其求导推导
查看>>
Android UI开源框架
查看>>
Java 构造时成员初始化的陷阱
查看>>
CentOS7.1 Liberty云平台之环境准备(2)
查看>>
js正则表达式test方法、exec方法与字符串search方法区别
查看>>
4.终端
查看>>
优秀的 Spring Cloud 开源软件
查看>>
mysql数据库的简单语句的介绍(1)
查看>>
HDU 2829 Lawrence (斜率DP)
查看>>
visual studio 2012 update3
查看>>
特征值和特征向量的几何意义、计算及其性质
查看>>
Spring framework3.2整合hibernate4.1报错:No Session found for current thread
查看>>
zqgame《每日一言》
查看>>
前端与后端分离的架构实例(一)
查看>>
LoadRunner性能分析指标解释
查看>>
OC语言类的本质和分类
查看>>
如何实现phpcms v9_4X版本tag的伪静态?
查看>>
w3c标准的selection对象介绍
查看>>