iPhone Sdk:How to Play Video Inside a View? Rather Than Fullscreen

iPhone SDK:How do you play video inside a view? Rather than fullscreen

As of the 3.2 SDK you can access the view property of MPMoviePlayerController, modify its frame and add it to your view hierarchy.

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
player.view.frame = CGRectMake(184, 200, 400, 300);
[self.view addSubview:player.view];
[player play];

There's an example here: http://www.devx.com/wireless/Article/44642/1954

How to play video inside a UIView without controls, like a background/wallpaper?

I've reached the goal with the native AVPlayer

1.Used AVFoundation:

#import <AVFoundation/AVFoundation.h>

2.Used property for player:

@property (nonatomic) AVPlayer *avPlayer;

3.Added video file into "Video" folder and added "Video" into project

4.Initialized the player

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 for event - video did play to the end

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:[self.avPlayer currentItem]]; 

6.Resumed video playing from the very start in related method

- (void)itemDidFinishPlaying:(NSNotification *)notification {
AVPlayerItem *player = [notification object];
[player seekToTime:kCMTimeZero];
}

Video doesn't play full screen in a given view in swift. Need help fixing it

Since you're using frames, I think you should try moving layout code later than viewDidLoad(). Perhaps, viewDidLayoutSubviews(), when the view size is determined and also invalidated when displaying parameters are changed (e.g. the screen orientation has changed).

Play Youtube video in a UIWebView without full screen

you set allowsinlinemediaplayback. but this feature on iPad. in iPhone not applicable. If you try play video with uiwebview on iPhone it will be played in full screen mode.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

Sample Image



Related Topics



Leave a reply



Submit