ich das Ziel mit dem nativen AVPlayer
1.Used AVFoundation erreicht haben:
#import <AVFoundation/AVFoundation.h>
2.Used Eigenschaft für Spieler:
@property (nonatomic) AVPlayer *avPlayer;
3.Added Videodatei in den Ordner "Video" und hinzugefügt "Video" in das Projekt
den Spieler
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"shutterstock_v885172.mp4" ofType:nil inDirectory:@"Video"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.avPlayer = [AVPlayer playerWithURL:fileURL];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
videoLayer.frame = self.view.bounds;
videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer:videoLayer];
[self.avPlayer play];
5.Subscribed für Event 4.Initialized - Video bis zum Ende gespielt hat
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:[self.avPlayer currentItem]];
6.Resumed Video
- (void)itemDidFinishPlaying:(NSNotification *)notification {
AVPlayerItem *player = [notification object];
[player seekToTime:kCMTimeZero];
}
Ist es lokales Video oder You Tube Video mit URL? – Vidhyanand
wird eine lokale Datei in das Projekt importiert. Tatsächlich gibt es mehrere Dateien (Videos) jeweils für separate ViewController –
Siehe http://stackoverflow.com/questions/17922017/display-video-inside-the-uiwebview-not-in-device-full-screen – Vidhyanand