Hi all,
I want to play a mp3 file for 1 minute in background from exe application.
I do not want any audio player UI for the same.
Anybody knows how to do it.?
Thanks in advance.
Hi all,
I want to play a mp3 file for 1 minute in background from exe application.
I do not want any audio player UI for the same.
Anybody knows how to do it.?
Thanks in advance.
What have you tied so far ?
in Symbian you can actually do exactly the same as you would do in application which is in foreground.
so far i am able to play audio with CPlayerUtility as explained on : http://www.developer.nokia.com/Commu...ng_audio_files
but i am not able to set the duration for playback.
I tried to stop player after 1 minute duration with
RTimer timer.After(timerStatus,duration);
but it hangs the app.
Last edited by akshay.raikwar; 2013-02-28 at 14:01. Reason: more info
How did you try it ?
and Which line in your code hangs ?
In general it should work just fine.
(In general it should work just fine, assuming that the timer is realized via an active object. See http://www.developer.nokia.com/Commu...implementation for a short example)
I dont know exactly on what line it is hanging but i know following :
iPlayerUtility->Play();
this is what i am using for playing file
RTimer timer;
TRequestStatus timerStatus;
timer.CreateLocal();
timer.After(timerStatus,constantTime);
User::WaitForRequest(timerStatus);
iPlayerUtility->Stop();
If i add this code to stop after 1 min everything hangs i can't access menu also (device e5)
and the play back starts after timer expiration
Make sure you read #5 and implement an active object. The audio player can not work while the code is doing a User::WaitForRequest.
Hi Working OK with active objects.
Thank you very much
But one more problem i am getting is i want repeat my mp3 file till time duration is reached so i have done
void CPlayerUtility::MapcPlayComplete(TInt /*aError*/)
{
//we want to play it continously repeatedly
if (iPlaying)
{
Play();
}
}
this change in CPlayerUtility clas.
then audio doesn't play at all
You might want to debug and see what parts of your code actually gets executed.
One more thing
My audio is playing in gui application.
But when i try the same code in exe application then audio doesn't play at all.
is there something in my code similar to User::WaitForRequest which is blocking my play back ?
My exe code is :
// connect to window server
RWsSession ws;
User::LeaveIfError(ws.Connect());
CleanupClosePushL(ws);
TRequestStatus status;
// create a window group for the thread
RWindowGroup wg(ws);
wg.Construct((TUint32)&wg, EFalse);
CleanupClosePushL(wg);
// capture a key
wg.CaptureKey('0', 0, 0);
wg.CaptureLongKey('0','0',0,0,0,ELongCaptureNormal);
// listen for the key presses
ws.EventReady(&status);
// hide this window group from the app switcher
wg.SetOrdinalPosition(-1);
wg.EnableReceiptOfFocus(EFalse);
CApaWindowGroupName* wn=CApaWindowGroupName::NewLC(ws);
wn->SetHidden(ETrue);
wn->SetWindowGroupName(wg);
// handle key events
for(;{
User::WaitForAnyRequest();
if (status.Int()==KErrNone) {
TWsEvent e;
ws.GetEvent(e);
TInt c;
TKeyEvent* aKeyEvent=e.Key();
c=aKeyEvent->iCode;
if( e.Key()->iRepeats > 0 )
{
{
CPlayerUtility* iPlayerUtility = CPlayerUtility::NewL();
//iPlayerUtility->PlayAlarmAndMakeCall();
iPlayerUtility->Play();
}
TInt wgid=ws.GetFocusWindowGroup();
ws.SendEventToWindowGroup(wgid, e);
}
ws.EventReady(&status);
// stop condition
}
// clean up
ws.EventReadyCancel();
CleanupStack::PopAndDestroy(3); //ws, wg, wn
Last edited by akshay.raikwar; 2013-03-01 at 06:32.
you should remove all for(;and User::WaitForAnyRequest(); and actually do real active object implementations. currently its impossible to see what would be happening really.
Symbian code is single-threaded by nature, and asynchronous events are handled sequentially with active objects. You can get some impressions from http://www.developer.nokia.com/Commu...tive_Scheduler how the events are dispatched.
If you block that single thread, asynchronous operations can not work. Create active objects for your timer, for your keyboard handler, etc., then start the scheduler loop.
Found a work around
Launching GUI app from exe and getting required work doneand then terminating app.
Will surely try with active objects as suggested whenever i get time
Thanks wizard_hu_ and symbianyucca for help
![]()