-2

How to show subtitle above video with an overlay view on iOS?

Cœur
  • 37,241
  • 25
  • 195
  • 267
libai
  • 195
  • 1
  • 2
  • 12

2 Answers2

2

You can create an overlay view using UILabel to show subtitle as below

//Overlay View
UILabel *lblOverlayView = [[UILabel alloc] init];
lblOverlayView.frame = CGRectMake(0, 459, 320, 21);
lblOverlayView.backgroundColor = [UIColor yellowColor];
lblOverlayView.alpha = 0.3f;
lblOverlayView.text = @"Video Subtitle";

then you can add it as a subview to the view of MPMoviePlayerController to show a subtitle while playing the video.

[_mpMoviePlayerController.view addSubview:lblOverlayView];

here, _mpMoviePlayerController is an object of MPMoviePlayerController. Hope this will help you to fulfill the requirements.

Kapil Mandlik
  • 174
  • 1
  • 1
  • thanks, at last I finally realized this function. thanks Kapil Mandlik, thanks internet,thanks everybody. – libai Jul 04 '11 at 12:54
  • your code is working, but your CGRectMake(0, 459, 320, 21); will likely go off visible area of iPhone screen in landscape mode. – bialix Apr 04 '13 at 09:06
1

Add a subview to the view showing the video and put it in front. This might help:

[myView bringSubviewToFront: subtitleView];
dasdom
  • 13,975
  • 2
  • 47
  • 58