0

私はウェブからビデオを再生するアプリを持っています

すべてが正常に動作します

しかし、ユーザーがメールなどを読むためにアプリを離れたとき

戻ってきてプレーヤーがいなくなった!! 大問題

だから、私はユーザーがアプリに戻った後に視聴を再開したい

ここに私のコードがあります

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterforground) name:UIApplicationWillEnterForegroundNotification object:nil];

メソッド

- (void) didEnterBackground
{
[theMovie.moviePlayer pause];
NSLog(@"Playing pause");
}

- (void) didEnterforground
{
[theMovie.moviePlayer play];
NSLog(@"Playing resume");
}

私は [self presentMoviePlayerViewControllerAnimated:theMovie]; を使用しています。ビューで再生しない

それはコードが機能するはずですが、何も機能しません

助けてください

前もって感謝します

4

1 に答える 1

0

答えは非常に簡単です。info.plist を編集します。
バックグラウンド機能の追加、必要なバックグラウンド モード、カテゴリの設定 アプリがオーディオを再生する

それを試してみてください!

于 2013-04-04T17:44:24.033 に答える