[[NSNotificationCenter defaultCenter] postNotificationName:@"WillResignActive" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"WillResignActive" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"WillEnterForeGround" object:nil];
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"DidBecomeActive" object:nil];
}
[super viewDidLoad];
// Do any additional setup after loading the view.
NSURL *url = [NSURL URLWithString:@"http://1080Digital.stream/playlist.m3u8"];
mp = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:mp];
mp.view.frame = self.view.bounds; //Set the size
self.view.backgroundColor=[UIColor clearColor];
mp.moviePlayer.controlStyle =MPMovieControlStyleNone;
mp.moviePlayer.scalingMode = MPMovieScalingModeFill;
mp.moviePlayer.repeatMode = MPMovieRepeatModeOne;
mp.moviePlayer.view.userInteractionEnabled = YES;
mp.moviePlayer.movieSourceType=MPMovieSourceTypeStreaming;
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(AppDidBecomeActive) name:@"DidBecomeActive" object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(EnteredBackground) name:@"WillResignActive" object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(EnteredForeground) name:@"WillEnterForeGround" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackStateChange)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:[mp moviePlayer]];
[mp.moviePlayer prepareToPlay];
[mp.moviePlayer prepareToPlay];
[mp.moviePlayer play];
[self.view addSubview:mp.view];
{
[[mp moviePlayer] play];
}
-(无效)appdidbeceactive
if(mp.moviePlayer.playbackState == MPMoviePlaybackStateInterrupted || mp.moviePlayer.playbackState == MPMoviePlaybackStateStopped || mp.moviePlayer.playbackState == MPMoviePlaybackStatePaused)
{
[mp.moviePlayer play];
}
[[mp moviePlayer] pause];
[mp.view removeFromSuperview];
[[mp moviePlayer] play];
}
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(EnteredForeground) name:@"WillEnterForeGround" object:nil];
and in
(void)applicationWillEnterForeground:(UIApplication *)application
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"WillEnterForeGround" object:nil];
}
如何后台播放音乐
我正在android上开发一个音乐播放器,该应用程序有两个活动(MainActivity和PlayActivity)。在Main活动中,我有一个包含歌曲列表的列表视图,在PlayActivity中,我有一个按钮来收听和暂停音乐。问题是,当我返回MainActivity并从listview中选择一首新歌时,第一首歌会继续在后台播放,而第二首歌也会开始播放。选择新歌曲时,如何停止第一首歌曲?(我不想让
这是在它自己的函数中,在同一个文件中: 你知道如何使用YouTube SDK在后台继续播放声音吗?还有,是不是可以只播放背景中的声音,不播放视频? 感谢任何帮助。
如何以编程方式禁止在Chrome Android进程的后台播放歌曲? 这是一个简单的页面示例,它在Chrome中播放歌曲: https://thomashunter.name/examples/chrome-audio-bug.html 注意这首歌是如何在背景中继续播放的。虽然对于点唱机来说很好,但它会让网络游戏的玩家发疯。 有没有办法禁用Chrome中单个音频元素的后台播放?或者,当页面失去焦点
我想在从后台转到前台时检测并计数(当活动可见时,增加计数)。我尝试在和
问题内容: 我正在尝试将Shell脚本移植到可读性更高的python版本。原始的shell脚本在后台使用“&”启动多个进程(实用程序,监视器等)。如何在python中达到相同的效果?我希望这些过程在Python脚本完成后不会消失。我敢肯定它与守护程序的概念有关,但是我找不到如何轻松实现此目的。 问题答案: 注意:此答案的最新版本比2009年发布时要少。现在建议在文档中使用其他答案中显示的模块 (请