MediaPlayer/MediaPlayer 视频播放
2013-11-02 15:04
267 查看
今天做了个MediaPlayer/MediaPlayer 小DEMO,具体要求是通过XML传过来的变量点击按钮一一对应播放相应的MP4.
1、添加MediaPlayer.framework
2、H文件
#import <UIKit/UIKit.h>
@interface news_show :
UIViewController
{
IBOutlet UIButton *button;
}
@property (nonatomic,retain)UIButton *button;
-(IBAction) pressedbutton:(id)sender;
@property (nonatomic,strong)
NSString *URL;//视频地址,只能用NSSTRING不能用UILABEL
3、M文件
#import "news_show.h"
#import "MediaPlayer/MediaPlayer.h"
@implementation news_show{
NSString *telNumber;
}
@synthesize imageView;
@synthesize dealTitle;
@synthesize deal;
@synthesize dealDesc;
@synthesize button;
@synthesize URL;//视频地址
。。。。。。。。。。。。。。。。。
URL = [deal
valueForKey:@"link"];
}
-(IBAction) pressedbutton:(id)sender
{
NSLog(@"按到我了");
[self
playVideo];
}
- (void)playVideo
{
//NSURL *movieUrl = [NSURL URLWithString:@"http://www.apple.com/ios/xzqcf/video/01.mp4"];//这是绝对路径
NSURL *movieUrl = [NSURL
URLWithString:URL];//这个是由XML提供的变量,不同介面有不同的相应连接
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController
alloc]
initWithContentURL:movieUrl];
[self
presentMoviePlayerViewControllerAnimated:player];
//[path release];
NSLog(@"play~");
}
- (void)dealloc {
[button
release];
[super
dealloc];
}
1、添加MediaPlayer.framework
2、H文件
#import <UIKit/UIKit.h>
@interface news_show :
UIViewController
{
IBOutlet UIButton *button;
}
@property (nonatomic,retain)UIButton *button;
-(IBAction) pressedbutton:(id)sender;
@property (nonatomic,strong)
NSString *URL;//视频地址,只能用NSSTRING不能用UILABEL
3、M文件
#import "news_show.h"
#import "MediaPlayer/MediaPlayer.h"
@implementation news_show{
NSString *telNumber;
}
@synthesize imageView;
@synthesize dealTitle;
@synthesize deal;
@synthesize dealDesc;
@synthesize button;
@synthesize URL;//视频地址
。。。。。。。。。。。。。。。。。
URL = [deal
valueForKey:@"link"];
}
-(IBAction) pressedbutton:(id)sender
{
NSLog(@"按到我了");
[self
playVideo];
}
- (void)playVideo
{
//NSURL *movieUrl = [NSURL URLWithString:@"http://www.apple.com/ios/xzqcf/video/01.mp4"];//这是绝对路径
NSURL *movieUrl = [NSURL
URLWithString:URL];//这个是由XML提供的变量,不同介面有不同的相应连接
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController
alloc]
initWithContentURL:movieUrl];
[self
presentMoviePlayerViewControllerAnimated:player];
//[path release];
NSLog(@"play~");
}
- (void)dealloc {
[button
release];
[super
dealloc];
}
相关文章推荐
- RPI pySerial 安装
- 5-4-2
- 4-3-2
- 为什么数组从0开始
- VC 获取鼠标当前位置坐标和RGB
- Xcode无法启动模拟器或者真机
- UVa 541 - Error Correction
- UML drawing tools
- JDBC批量插入、批量删除、批量更新
- Hadoop RPC概述
- UVA 706 - LCD Display(液晶显示器)
- OAF FlexField中数据库与页面的前后台数据类型转换
- Morning Walk UVA 10596
- 事件驱动I/O模型
- Oracle 存储过程 无法编译 解决方法
- Leetcode: Linked List Cycle II
- 分治法求最大子序列
- IOS UIColor 自定义颜色
- MINI2440+UDA1341TS分析之三
- virtual box上面安装centos