加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

MediaPlayer/MediaPlayer 视频播放

发布时间:2020-12-15 23:18:47 所属栏目:百科 来源:网络整理
导读:今天做了个MediaPlayer/MediaPlayer 小DEMO,具体要求是通过XML传过来的变量点击按钮一一对应播放相应的MP4. 1、添加MediaPlayer.framework 2、H文件 #import UIKit/UIKit.h @interface news_show : UIViewController { IBOutlet UIButton *button; } @prope

今天做了个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;

) 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];

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读