×

Discussion Board

Results 1 to 2 of 2

Thread: Player Problem

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    136

    Player Problem

    hi,

    I am Trying to Implement Payer,( Not exactly Player)

    In my app i am playing sound file which starts playing when i request Play n continue play repeatedly till i say stop playing on some condition....

    My problem is some time Playing stops and some time Playing doesn't stop....

    My implementation is as follows:

    /*
    * AudioPlayer.cpp
    *
    * Created on: Jan 19, 2012
    * Author:
    */

    #include "AudioPlayer.h"
    #include <MdaAudioTonePlayer.h>
    #include <eikmenup.h>

    CPlayerUtility* CPlayerUtility::NewL(const TDesC& aFileName)
    {
    CPlayerUtility* self = NewLC(aFileName);
    CleanupStack::Pop(self);
    return self;
    }

    CPlayerUtility* CPlayerUtility::NewLC(const TDesC& aFileName)
    {
    CPlayerUtility* self = new (ELeave) CPlayerUtility();
    CleanupStack::PushL(self);
    self->ConstructL(aFileName);
    return self;
    }

    CPlayerUtility::~CPlayerUtility()
    {
    generatePlaylog(_L("In Player delete IN FunctionL"));
    if (iPlayUtility)
    {
    iPlayUtility->Stop();
    iPlayUtility->Close();
    }

    delete iPlayUtility;
    generatePlaylog(_L("In Player delete out FunctionL"));
    }

    CPlayerUtility::CPlayerUtility()
    {
    }

    void CPlayerUtility::ConstructL(const TDesC& aFileName)
    {
    generatePlaylog(_L("In Player construct L"));
    iPlayUtility = CMdaAudioPlayerUtility::NewFilePlayerL(aFileName, *this);
    iPlaying = iPrepared = EFalse;
    }

    void CPlayerUtility::Play()
    {
    generatePlaylog(_L("In Player Play IN FunctionL"));
    iPlayUtility->Play();
    iPlaying = ETrue;
    generatePlaylog(_L("In Player Play OUT FunctionL"));
    }

    void CPlayerUtility::Stop()
    {
    generatePlaylog(_L("In Player Stop IN FunctionL"));
    iPlayUtility->Stop();
    iPlaying = EFalse;
    generatePlaylog(_L("In Player Stop out FunctionL"));
    }

    void CPlayerUtility::MapcPlayComplete(TInt aError)
    {
    generatePlaylog(_L("In Player MapcPlayComplete IN FunctionL"));
    if (aError == KErrNone)
    {
    iPlaying = EFalse;
    iPrepared = ETrue;
    iPlayUtility->SetVolume(iPlayUtility->MaxVolume());
    iPlayUtility->Play();
    generatePlaylog(_L("In Player MapcPlayComplete out FunctionL"));
    }
    else
    {
    TBuf<50> temp1;
    temp1.AppendNum(aError);
    generatePlaylog(_L("Error is"));
    generatePlaylog(temp1);
    }

    }

    void CPlayerUtility::MapcInitComplete(TInt aError,
    const TTimeIntervalMicroSeconds& /*aDuration*/)
    {
    generatePlaylog(_L("In Player MapcInitComplete IN FunctionL"));
    if (aError == KErrNone)
    {
    iPrepared = ETrue;
    iPlayUtility->SetVolume(iPlayUtility->MaxVolume());
    iPlayUtility->Play();
    }
    generatePlaylog(_L("In Player MapcInitComplete out FunctionL"));
    }

    void CPlayerUtility::generatePlaylog(const TDesC& data)
    {
    TBuf<500> writedata;
    TBuf8<500> writedata8;
    TBuf<500> timetext;
    TBuf<500> datetext;

    TBuf<500> timetext1;
    TBuf<500> datetext1;

    writedata.Delete(0, 500);
    writedata8.Delete(0, 500);
    _LIT(KFormat1, "%:0%H%:1%T%:2%S%:3");
    _LIT(KDateFormat, "%Y%*M%D%3-%2-%1");

    TTime time;
    time.HomeTime();

    timetext.Delete(0, 50);
    datetext.Delete(0, 50);

    TDateTime curTime = time.DateTime();
    time.FormatL(timetext, KFormat1);
    time.FormatL(datetext, KDateFormat);

    timetext1.Copy(timetext);
    datetext1.Copy(datetext);

    writedata.Append(_L("\r\n"));
    writedata.Append(data);
    writedata.Append(_L(" "));
    writedata.Append(datetext1);
    writedata.Append(_L(" "));
    writedata.Append(timetext1);

    writedata8.Copy(writedata);
    RFs aFsk1;
    aFsk1.Connect();
    _LIT(Ktfile1, "C:\\data\\others\\Mobi\\LogFile.txt");
    RFs fsSessiona;
    fsSessiona.Connect();
    RFile filea;
    filea.Open(fsSessiona, Ktfile1, EFileWrite);
    TInt posa = 0;
    filea.Seek(ESeekEnd, posa);

    filea.Write(posa, writedata8);
    filea.Close();
    fsSessiona.Close();
    }


    when there is request to play i do

    iMyPlayer = CPlayerUtility::NewL(KMusicFile);

    and when i want to stop playing in that fn code is



    if(iMyPlayer)
    {

    iMyPlayer->Stop();
    delete iMyPlayer;
    iMyPlayer = NULL;
    };


    if i remove ifcondition then some time my app crashes at stop fun of player

    Please can any one help in solving my problem...


    Thanks n advance
    Cholker

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: Player Problem

    Basically when your app crashes, you should get the panic code for the crash: http://www.developer.nokia.com/Commu...ded_panic_code without it, its really hard to know what is going wrong in there.

    Secondly if you have problems with logic, then you need to debug on what is happening with the logic. if you can , use emulator to step-by step execute the lines where the logic is failing to see what the values of each variable efecting the logic are. And then debug more to see why they are not what they are supposed to be.

Similar Threads

  1. Reconnection problem FL2.1 on FL3 player
    By jeremija in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2009-07-30, 16:41
  2. Problem creating player on N81
    By lamiaaMB in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2008-06-24, 19:03
  3. MP3 player problem
    By shikhakhandelwal in forum Symbian Media (Closed)
    Replies: 10
    Last Post: 2008-03-18, 09:37
  4. problem in mp3 player
    By punit4me in forum Mobile Java General
    Replies: 1
    Last Post: 2007-12-08, 10:14
  5. Audio Player Problem
    By kbrooking in forum Mobile Java General
    Replies: 3
    Last Post: 2006-05-12, 10:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×