目标C:如何在Movie Player视图中插入文本?

时间:2015-09-08 05:04:28

标签: objective-c

我正在制作一个Apache Cordova应用程序。 在这个应用程序中,我使用了插件:Cordova Streaming Media插件

链接是:https://github.com/nchutchind/Streaming-Media-Cordova-Plugin

我想插入一个“Hello World!”我的电影上有标签,但我不知道该怎么做。

我认为脚本是:StreamingMedia.m 链接是:https://github.com/nchutchind/Streaming-Media-Cordova-Plugin/blob/master/src/ios/StreamingMedia.m

功能是:startPlayer()

你能告诉我我的错误在哪里:

-(void)startPlayer:(NSString*)uri {
    NSURL *url = [NSURL URLWithString:uri];

    moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:url];

// Listen for playback finishing
   [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayer];
// Listen for click on the "Done" button
   [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(doneButtonClick:)
                                             name:MPMoviePlayerWillExitFullscreenNotification
                                           object:nil];
// Listen for orientation change
   [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(orientationChanged:)
                                             name:UIDeviceOrientationDidChangeNotification
                                           object:nil];

    moviePlayer.controlStyle = MPMovieControlStyleDefault;

    moviePlayer.shouldAutoplay = YES;
if (imageView != nil) {
    [moviePlayer.backgroundView setAutoresizesSubviews:YES];
    [moviePlayer.backgroundView addSubview:imageView];
}

    moviePlayer.backgroundView.backgroundColor = backgroundColor;

    [self.viewController.view addSubview:moviePlayer.view];

// Note: animating does a fade to black, which may not match background color
    [moviePlayer setFullscreen:YES animated:NO];



     // Here my code :

     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 0, 0)];
     label.text = @"Hello World!";

     CGRect frame = label.frame;

     frame.origin.x = 100; 
     frame.origin.y = 50;

     label.frame = frame;

     [self.viewController.view addSubview:label]; 
}

谢谢!

1 个答案:

答案 0 :(得分:0)

您有两种选择:

  1. 您可以将视图添加到应用程序窗口/根控制器视图。
  2. 创建自定义控制器并添加到他的视图MPMoviePlayerController之类的 子视图。