0

请帮助我,因为我是新开发人员

视频在完整模式下停止,这意味着当您单击右下角的两个小箭头时,只要单击箭头,视频就会在小窗口中播放 视频停止并显示屏幕上正在加载

为什么视频没有以完整模式和横向模式播放。我也发布了 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
4

1 回答 1

0

我知道这是一个非常古老的帖子来回答。但我认为这可能对其他人有帮助。正如我自己在搜索相同答案时遇到的问题。

而不是仅仅放置 [videoPlayer stop]; 在 viewWillDissappear 方法中,将代码放在下面 if (!videoPlayer.fullscreen) { [videoPlayer stop]; }

于 2013-12-13T10:17:49.110 回答