代码之家  ›  专栏  ›  技术社区  ›  David Salzer

iPhone MPMoviePlayerController上的下一个/上一个按钮

  •  10
  • David Salzer  · 技术社区  · 15 年前

    使用MPMoviePlayerController时,“播放”按钮周围有“下一步”和“上一步”按钮。

    单击通知时如何获取通知? 是否有方法向MPMoviePlayerController提供内容列表(数组)?

    3 回复  |  直到 12 年前
        1
  •  6
  •   Ransom Weaver Ransom Weaver    15 年前

    Nathan说得对,如果你想要按钮通知,就需要为播放器实现自己的UI。不过,您可以从播放器获得有关播放状态的通知。

    - (void) registerForMediaPlayerNotifications {
    
        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    
        [notificationCenter addObserver: self
                               selector: @selector (handle_NowPlayingItemChanged:)
                                   name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification
                                 object: musicPlayer];
    
        [notificationCenter addObserver: self
                               selector: @selector (handle_PlaybackStateChanged:)
                                   name: MPMusicPlayerControllerPlaybackStateDidChangeNotification
                                 object: musicPlayer];
    
        /*
         // This sample doesn't use libray change notifications; this code is here to show how
         //     it's done if you need it.
         [notificationCenter addObserver: self
         selector: @selector (handle_iPodLibraryChanged:)
         name: MPMediaLibraryDidChangeNotification
         object: musicPlayer];
    
         [[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
         */
    
        [musicPlayer beginGeneratingPlaybackNotifications];
    }
        2
  •  4
  •   Nathan de Vries    15 年前

    MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc]
        initWithContentURL:someUrl];
    moviePlayer.movieControlMode = MPMovieControlModeHidden;
    [moviePlayer play];
    
    NSArray* windows = [[UIApplication sharedApplication] windows];
    if ([windows count] > 1) {
      UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
      [moviePlayerWindow addSubview:yourCustomOverlayView];
    }
    

    不理想,但标准控件很容易重新实现。

        3
  •  0
  •   rptwsthi    12 年前

    我认为你对这件事没有多少控制权 MPMoviePlayerController . 它是一个标准组件,基本上可以开始和停止播放电影,而不需要其他任何东西。