Note that there are some explanatory texts on larger screens.

plurals
  1. POObserving currentPlaybackTime and showing an overlay at intervals
    primarykey
    data
    text
    <p>I’m making a video that shows overlays at certain intervals of a video. I’ve managed to get the video to play. Now my objective is to watch/observe the currentPlaybackTime value and pause the video when it hits 2 seconds. </p> <p>After some research found that currentPlaybackTime does not support KOV. So I need to implement <a href="https://stackoverflow.com/questions/5791273/how-to-add-a-kvo-to-mpmovieplayer-currentplaybacktime">this solution</a> but I have no idea where to put the code - I’m very new to Objective C. I keep trying to put it in the ViewController (My only view) but the way its written hints to it being placed somewhere else… </p> <p>Should I create a new controller for it? Or do I override methods from the MediaPlayer framework?</p> <p>Here's my code:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;MediaPlayer/MediaPlayer.h&gt; @interface ViewController : UIViewController @property (strong, nonatomic) MPMoviePlayerController *movieController; @property(nonatomic) NSTimeInterval currentPlaybackTime; @end #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)viewDidAppear:(BOOL)animated { self.movieController = [[MPMoviePlayerController alloc] init]; NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"]; NSURL *movieURL = [NSURL fileURLWithPath:moviePath]; self.movieController = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; [self.movieController.view setFrame:CGRectMake (0, 0, 480, 326)]; [self.view addSubview:self.movieController.view]; [self.movieController play]; [self.movieController currentPlaybackTime]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload