MediaPlayer/MediaPlayer 视频播放

前端之家收集整理的这篇文章主要介绍了MediaPlayer/MediaPlayer 视频播放前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

}

原文链接:https://www.f2er.com/xml/299620.html

猜你在找的XML相关文章