仅当我单击全屏选项卡时才以纵向播放视频,它会停止播放(Xcode 4.6)ios6.1
Posted
技术标签:
【中文标题】仅当我单击全屏选项卡时才以纵向播放视频,它会停止播放(Xcode 4.6)ios6.1【英文标题】:video playing in portrait only if I click on full screen tab its stops playing (Xcode 4.6) ios6.1 【发布时间】:2013-06-09 21:22:22 【问题描述】:请帮助我,因为我是一名新开发人员
视频在完整模式下停止,这意味着当您在小窗口中播放视频时单击右下角的两个小箭头 一旦您单击箭头,视频就会停止,并说正在屏幕上加载
为什么视频不能以完整模式和横向模式播放。 我也发布了 m & h 文件
//
// Mynewpage.h
//
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface Mynewpage : UIViewController
NSString *urlname;
MPMoviePlayerController *player;
@property(nonatomic,retain)NSString *urlname;
@end
下一个
//
// Mynewpage.m
#import "Mynewpage.h"
#import <MediaPlayer/MediaPlayer.h>
@implementation Mynewpage
@synthesize urlname;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
// Custom initialization
return self;
- (void)didReceiveMemoryWarning
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
#pragma mark - View lifecycle
- (void)viewDidLoad
NSString *url = [[NSBundle mainBundle]
pathForResource:urlname
ofType:@"mp4"];
player =
[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
player.view.frame = CGRectMake(0,85, 320, 255);
[self.view addSubview:player.view];
[player play];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
-(void)viewDidDisappear:(BOOL)animated
NSLog(@"hi");
[player stop];
- (void)viewDidUnload
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
@end
===================
//
// Newpage.h
#import <UIKit/UIKit.h>
#import "Custom_cell.h"
@interface Newpage : UIViewController
NSMutableArray *mydata;
NSMutableArray *myaudio;
// IBOutlet Custom_cell *owncell
@end
下一个
//
// Newpage.m
#import "Newpage.h"
#import "Custom_cell.h"
#import "Mynewpage.h"
@implementation Newpage
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
// Custom initialization
return self;
- (void)didReceiveMemoryWarning
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
#pragma mark - View lifecycle
- (void)viewDidLoad
mydata = [[NSMutableArray alloc]initWithObjects:@"1-রাসূলুল্লাহ সাল্লাল্লাহু আলাইহি ওয়াসাল্লামের সালাত আদায় পদ্ধতি",@"2-রাসূলুল্লাহ সাল্লাল্লাহু আলাইহি ওয়াসাল্লামের সালাত আদায় পদ্ধতি",nil];
myaudio = [[NSMutableArray alloc]initWithObjects:@"1",@"2",nil];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
return 1;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [mydata count];
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @"Custom_cell";
Custom_cell *cell = (Custom_cell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (indexPath.section == 0)
if (cell == nil)
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"Custom_cell" owner:self options:nil];
//cell = [[[Custom_cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
for (id currentObject in topLevelObjects)
if ([currentObject isKindOfClass:[UITableViewCell class]])
cell = (Custom_cell *) currentObject;
// cell.backgroundView.backgroundColor = [UIColor clearColor];
break;
cell.lbl.text = [mydata objectAtIndex:indexPath.row];
return cell;
// [myString release];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Mynewpage *page = [[Mynewpage alloc]init];
page.urlname = [myaudio objectAtIndex:indexPath.row];
[self.navigationController pushViewController:page animated:YES];
- (void)viewDidUnload
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
@end
【问题讨论】:
【参考方案1】:我知道这是一个非常古老的帖子。但我认为这可能对其他人有帮助。正如我自己在搜索相同答案时遇到的问题。
而不仅仅是把 [videoPlayer stop];在 viewWillDissappear 方法中,放下面的代码 如果(!videoPlayer.fullscreen) [视频播放器停止];
【讨论】:
以上是关于仅当我单击全屏选项卡时才以纵向播放视频,它会停止播放(Xcode 4.6)ios6.1的主要内容,如果未能解决你的问题,请参考以下文章
当我单击“AboSee”选项卡时,它会打开选项卡,但不显示选项卡栏
当我从一个选项卡单击到另一个选项卡时,如何使TabLayout中的选项卡不可滚动