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
Related Topics
Why Can't I Invert My Image Back to Original with Cifilter in My Swift iOS App
If No Table View Results, Display "No Results" on Screen
Uibutton Touch Is Delayed When in Uiscrollview
Refresh Uipageviewcontroller - Reorder Pages and Add New Pages
Tap on a Part of Text of Uilabel
How to Write an Objective-C Completion Block
Repeating Local Notification Daily at a Set Time with Swift
iOS Uiview Subclass, Draw See-Through Text to Background
iOS Wifi Scan, Signal Strength
Uitableviewcells with Uibutton Overlaps While Scrolling
Ask for User Permission to Receive Uilocalnotifications in iOS 8
Swift Stack and Heap Understanding
Coredata Get Distinct Values of Attribute
How to Draw Radial Gradients in a Calayer
Ios7 Status Bar Hide/Show on Select Controllers
Xmppframework - Retrieve Archived Messages from Openfire Server
How to Retrieve Keystrokes from a Custom Keyboard on an iOS App