#import
“ViewController.h”
#import
<MediaPlayer/MediaPlayer.h>
#import
<AVFoundation/AVFoundation.h>
@interface
ViewController
()
@property
(
strong
,
nonatomic
)
AVPlayer
*avPlayer;
@property
(
strong
,
nonatomic
)
MPMoviePlayerController
*mpPlayer;
@end
@implementation
ViewController
– (
void
)viewDidLoad {
[
super
viewDidLoad
];
// Do any additional setup after loading the view, typically from a nib.
}
– (
void
)didReceiveMemoryWarning {
[
super
didReceiveMemoryWarning
];
// Dispose of any resources that can be recreated.
}
– (
void
)touchesBegan:(
NSSet
*)touches withEvent:(
UIEvent
*)event
{
//192.168.0.125
NSURL
*url=[
NSURL
URLWithString
:
@”http://192.168.0.125:8080/WYServer/resources/htmls/Go.mp3″
];
NSURL
*urlMoive=[
NSURL
URLWithString
:
@”http://192.168.0.125:8080/WYServer/resources/videos/minion_01.mp4″
];
// self.avPlayer = [[AVPlayer alloc] initWithURL:url];
// [self.avPlayer play];
//——
方式
1-
-----
// self.mpPlayer=[[MPMoviePlayerController alloc] initWithContentURL:urlMoive];
// [self.view addSubview:self.mpPlayer.view];
// [self.mpPlayer setFullscreen:YES];
//
// [self.mpPlayer play];
//——
方式
2-
-----
[
self
presentMoviePlayerViewControllerAnimated
:[[
MPMoviePlayerViewController
alloc
]
initWithContentURL
:urlMoive]];
}
@end
