我在使用 MPMoviePlayerController 时遇到问题

发布于 2024-11-25 18:34:14 字数 175 浏览 0 评论 0原文

我在 MPMoviePlayerController 方面遇到了很多问题。

当我将视频从正常屏幕切换到全屏时,会出现一个栏。上面有用于前进/后退播放/暂停的按钮,但这些按钮无法根据我的要求正常工作,即单击前进/后退按钮时,它不会更改下一个/上一个视频; MPMoviePlayerController 在单击时停止...

I face lots of problems with MPMoviePlayerController.

When I switch my video from normal to full screen one bar appears. On that there are buttons for forward/backward play/pause, but those buttons don't work properly according to my requirement i.e. on single click on forward/rewind button it is not changing next/previous videos; the MPMoviePlayerController stops on its click...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧伤慢歌 2024-12-02 18:34:14

尝试注册通知。

MPMoviePlaybackState
Constants describing the current playback state of the movie player.

enum {
   MPMoviePlaybackStateStopped,
   MPMoviePlaybackStatePlaying,
   MPMoviePlaybackStatePaused,
   MPMoviePlaybackStateInterrupted,
   MPMoviePlaybackStateSeekingForward,
   MPMoviePlaybackStateSeekingBackward
};
typedef NSInteger MPMoviePlaybackState;

try registering for notifications.

MPMoviePlaybackState
Constants describing the current playback state of the movie player.

enum {
   MPMoviePlaybackStateStopped,
   MPMoviePlaybackStatePlaying,
   MPMoviePlaybackStatePaused,
   MPMoviePlaybackStateInterrupted,
   MPMoviePlaybackStateSeekingForward,
   MPMoviePlaybackStateSeekingBackward
};
typedef NSInteger MPMoviePlaybackState;
黑色毁心梦 2024-12-02 18:34:14

这样做

-(void)videoClick:(id)sender
{
    bi3.enabled=NO;
    videoTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    videoTable.dataSource = self;
    videoTable.delegate = self;
    videoTable.rowHeight=100;
    videoTable.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
    videoTable.separatorColor=[UIColor brownColor];
    navTitleLabel.text = [NSString stringWithFormat:@"xxx"];
    [webView addSubview:videoTable];

}

-(void)videoFile:(NSString *)moviepath
{

    //[tools setHidden:YES];
//  bi3.enabled=NO;

    // Register to receive a notification when the movie scaling mode has changed. 


    //NSString *moviePath = [bundle pathForResource:@"video" ofType:@"mp4"];
    NSURL  *movieURL1 = [[NSURL fileURLWithPath:moviepath] retain];
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL1];
    [theMovie setControlStyle:MPMovieControlStyleFullscreen];
    [theMovie play];
    MPMoviePlayerViewController *moviePlayer11 = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL1];
    [self presentMoviePlayerViewControllerAnimated:moviePlayer11];  // Override point for customization after app launch    
    // [navigationController.view addSubview:];
    //[self.view addSubview:mpMCtr.view];



}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
    bi3.enabled=YES;
    [tools setHidden:NO];
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:player];
   // [player stop];
    //[self.view removeFromSuperview];
[player.view removeFromSuperview];

       [player autorelease];    
}

- (void) moviePlayBackDidFinish:(NSNotification*)aNotification
{

    MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:theMovie];
    //[mpMCtr stop];

    [theMovie.view removeFromSuperview];
    [videoTable removeFromSuperview];

}
-(void)backview:(id)sender
{
    [mpMCtr stop];
    [mpMCtr.view removeFromSuperview];
    [videoTable removeFromSuperview];
    [self.navigationController popViewControllerAnimated:YES];
}

do like this

-(void)videoClick:(id)sender
{
    bi3.enabled=NO;
    videoTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    videoTable.dataSource = self;
    videoTable.delegate = self;
    videoTable.rowHeight=100;
    videoTable.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
    videoTable.separatorColor=[UIColor brownColor];
    navTitleLabel.text = [NSString stringWithFormat:@"xxx"];
    [webView addSubview:videoTable];

}

-(void)videoFile:(NSString *)moviepath
{

    //[tools setHidden:YES];
//  bi3.enabled=NO;

    // Register to receive a notification when the movie scaling mode has changed. 


    //NSString *moviePath = [bundle pathForResource:@"video" ofType:@"mp4"];
    NSURL  *movieURL1 = [[NSURL fileURLWithPath:moviepath] retain];
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL1];
    [theMovie setControlStyle:MPMovieControlStyleFullscreen];
    [theMovie play];
    MPMoviePlayerViewController *moviePlayer11 = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL1];
    [self presentMoviePlayerViewControllerAnimated:moviePlayer11];  // Override point for customization after app launch    
    // [navigationController.view addSubview:];
    //[self.view addSubview:mpMCtr.view];



}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
    bi3.enabled=YES;
    [tools setHidden:NO];
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:player];
   // [player stop];
    //[self.view removeFromSuperview];
[player.view removeFromSuperview];

       [player autorelease];    
}

- (void) moviePlayBackDidFinish:(NSNotification*)aNotification
{

    MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:theMovie];
    //[mpMCtr stop];

    [theMovie.view removeFromSuperview];
    [videoTable removeFromSuperview];

}
-(void)backview:(id)sender
{
    [mpMCtr stop];
    [mpMCtr.view removeFromSuperview];
    [videoTable removeFromSuperview];
    [self.navigationController popViewControllerAnimated:YES];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文