Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 05:38, 26 July 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Symbian音频播放中断后错误的捕获

From Wiki
Jump to: navigation, search
Article Metadata

文章
Amazing110 在 22 Mar 2012 创建
最后由 hamishwillee 在 26 Jul 2012 编辑

Contents

Introduction

我们使用CMdaAudioPlayerUtility来播放音频时,正在播放时,这是我们打开FM收音机,那么当前程序的音频播放将被中断,假如我们不去捕获,处理这个中断错误的话,我们应用程序就会不能设置为正确的状态(播放,暂停,终止等) 那么如何来获取这个中断的信息呢?


Summary

我们可以通过MMdaAudioPlayerCallback这个回调来处理:

void CPlayerEngine::MapcPlayComplete(TInt aError)
{
if (aError == KErrNone)
{
iState = EPrepared;
CEikLabel* label = static_cast<CEikLabel*>(iContainer->ComponentControl(0));
label->SetTextL(_L("Player is finished"));
label->SetExtentToWholeScreen();
label->DrawDeferred();
}
else
{
iState = EInitialising;
CEikLabel* label = static_cast<CEikLabel*>(iContainer->ComponentControl(0));
TBuf<40> string(_L("Get a error when playing"));
string.AppendNum(aError);
label->SetTextL(string);
label->SetExtentToWholeScreen();
label->DrawDeferred();
}
}


通过这个函数,我们会得到一个“KErrInUse”的错误代码,然后我们就知道此时设备被占用,播放被中断,然后根据需要我们就能够做出恰当的处理。

例程下载

  1. 音频播放 例程

相关链接

Portal:Qt (Chinese)

This page was last modified on 26 July 2012, at 05:38.
227 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×