我正在研究背景音乐,来自网站的流媒体音乐。我试图通过网络每隔3秒获取有关音乐的信息,即使应用程序已关闭。一切都在工作,除了我的自动收报机不在后台工作。
这是我的代码:
public sealed class AudioTask : IBackgroundTask
{
#region Music properties
private void setTicker()
{
AutoResetEvent _refreshWaiter = new AutoResetEvent(true);
dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += dispatcherTimer_Tick;
dispatcherTimer.Interval = new TimeSpan(0, 0, 3);
dispatcherTimer.Start();
}
private void dispatcherTimer_Tick(object sender, object e)
{
GetInfoAboutMusic();
}
}
也许有DispatcherTime
之类的东西?我该怎么用?
答案 0 :(得分:0)
如果没有看到更多代码,很难提出正确的建议。您应该在Background Tasks in Windows Store Apps上阅读此文章以及您可以找到引用IBackgroundTask
的其他人。
还有How to play background music in windows phone 8.1 with xaml and c#?有一些很好的信息可能会让你解锁。