Commit 1f901be3 authored by Brent Vatne's avatar Brent Vatne
Browse files

Pause video when the app is backgrounded

parent 30374adf
Loading
Loading
Loading
Loading
+26 −0
Changes for RCTVideo.m: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,11 +54,37 @@ static NSString *const statusKeyPath = @"status";
    _pendingSeek = false;
    _pendingSeekTime = 0.0f;
    _lastSeekTime = 0.0f;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                          selector:@selector(applicationWillResignActive:)
                                          name:UIApplicationWillResignActiveNotification
                                          object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                          selector:@selector(applicationWillEnterForeground:)
                                          name:UIApplicationWillEnterForegroundNotification
                                          object:nil];
  }

  return self;
}

#pragma mark - App lifecycle handlers

- (void)applicationWillResignActive:(NSNotification *)notification
{
  if (!_paused) {
    [self stopProgressTimer];
    [_player pause];
  }
}

- (void)applicationWillEnterForeground:(NSNotification *)notification
{
  [self startProgressTimer];
  [self applyModifiers];
}

#pragma mark - Progress

- (void)sendProgressUpdate
+1 −1
Changes for package.json: 1 added line, 1 removed line.
Original line number Diff line number Diff line
{
  "name": "react-native-video",
  "version": "0.4.7",
  "version": "0.4.8",
  "description": "A <Video /> element for react-native",
  "main": "Video.ios.js",
  "author": "Brent Vatne <brentvatne@gmail.com> (https://github.com/brentvatne)",