Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AVPlayer *player = [AVPlayer playerWithURL:fileURL];
- AVPlayerViewController *playerViewController = [AVPlayerViewController new];
- [player pause];
- [player play];
- playerViewController.player = player;
- [self addChildViewController: playerViewController];
- [self.view addSubview: playerViewController.view];
- //[playerViewController.player play];//Used to Play On start
- [self presentViewController:playerViewController animated:YES completion:nil];
- #import <UIKit/UIKit.h>
- #import <AVKit/AVKit.h>
- @interface ViewController : UIViewController
- @property (strong, nonatomic) AVPlayerViewController *playerViewController;
- - (IBAction)actionPlayVideo:(id)sender;
- @end
- #import "ViewController.h"
- @interface ViewController (){
- NSURL *vedioURL;
- }
- @end
- @implementation ViewController
- @synthesize playerViewController;
- - (IBAction)actionPlayVideo:(id)sender{
- NSString *fullpath = [[self documentsDirectory] stringByAppendingPathComponent:@"yourdate.3gp"];
- vedioURL =[NSURL fileURLWithPath:fullpath];
- AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:vedioURL];
- AVPlayer* playVideo = [[AVPlayer alloc] initWithPlayerItem:playerItem];
- playerViewController = [[AVPlayerViewController alloc] init];
- playerViewController.player = playVideo;
- playerViewController.player.volume = 0;
- playerViewController.view.frame = self.view.bounds;
- [self.view addSubview:playerViewController.view];
- [playVideo play];
- }
- -(NSString *)documentsDirectory{
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- return documentsDirectory;
- }
- NSURL *videoURL = [NSURL fileURLWithPath:filePath];
- //filePath may be from the Bundle or from the Saved file Directory, it is just the path for the video
- AVPlayer *player = [AVPlayer playerWithURL:videoURL];
- AVPlayerViewController *playerViewController = [AVPlayerViewController new];
- playerViewController.player = player;
- //[playerViewController.player play];//Used to Play On start
- [self presentViewController:playerViewController animated:YES completion:nil];
- #import <AVFoundation/AVFoundation.h>
- #import <AVKit/AVKit.h>
- NSString *filepath = [[NSBundle mainBundle] pathForResource:@"08-03-201711:21:67" ofType:@"3gp"];
- NSURL *fileURL = [NSURL fileURLWithPath:filepath];
- AVPlayer *player = [AVPlayer playerWithURL:fileURL];
- AVPlayerViewController *playerViewController = [AVPlayerViewController new];
- [player pause];
- [player play];
- playerViewController.player = player;
- [self addChildViewController: playerViewController];
- [self.view addSubview: playerViewController.view];
Add Comment
Please, Sign In to add comment