📄 oggplay.cpp
字号:
}
#else
iAppView->iOggFiles->CreateDb(iCoeEnv->FsSession());
#endif
iAppView->iOggFiles->WriteDbL(iDbFileName, iCoeEnv->FsSession());
TBuf<16> dummy;
iAppView->FillView(ETop, ETop, dummy);
iAppView->Invalidate();
break;
}
case EOggSkinOne:
case EOggSkinTwo:
case EOggSkinThree:
case EOggSkinFour:
case EOggSkinFive:
case EOggSkinSix:
case EOggSkinSeven:
case EOggSkinEight:
case EOggSkinNine:
case EOggSkinTen:
{
iCurrentSkin = aCommand-EOggSkinOne;
TFileName buf(iSkinFileDir);
if (iCurrentSkin >= iSkins->MdcaCount())
{
if (iCurrentSkin == 0)
{
// There are no skins at all, so leave with KErrNotFound
User::Leave(KErrNotFound);
}
else
{
// The index is out of range, so reset to the first skin
iCurrentSkin = 0;
}
}
buf.Append((*iSkins)[iCurrentSkin]);
iAppView->ReadSkin(buf);
iAppView->Update();
iAppView->Invalidate();
break;
}
#if defined(SERIES60) || defined(SERIES80)
case EUserStopPlayingCBA : {
HandleCommandL(EOggStop);
break;
}
case EUserPauseCBA : {
iOggPlayback->Pause(); // does NOT call UpdateS60Softkeys
iAppView->Update();
UpdateSoftkeys();
break;
}
case EUserPlayCBA : {
HandleCommandL(EOggPlay);
iAppView->Update();
break;
}
case EUserBackCBA : {
SelectPreviousView();
break;
}
case EOggUserHotkeys :
ActivateOggViewL(KOggPlayUidUserView);
break;
case EUserHotKeyCBABack: {
ActivateOggViewL(KOggPlayUidFOView);
}
break;
case EUserFastForward : {
TInt64 pos= iOggPlayback->Position() + KFfRwdStep;
iOggPlayback->SetPosition(pos);
iAppView->UpdateSongPosition();
}
break;
case EUserRewind : {
TInt64 pos= iOggPlayback->Position() - KFfRwdStep;
iOggPlayback->SetPosition(pos);
iAppView->UpdateSongPosition();
}
break;
case EUserListBoxPageDown :
iAppView->ListBoxPageDown();
break;
case EUserListBoxPageUp:
iAppView->ListBoxPageUp();
break;
case EUserVolumeHelp: {
TBuf<256> buf;
iEikonEnv->ReadResource(buf, R_OGG_STRING_14);
User::InfoPrint(buf);
break;
}
case EVolumeBoostUp:
{
TGainType currentGain = (TGainType) iSettings.iGainType;
TInt newGain = currentGain + 1;
if (newGain<=EStatic12dB)
SetVolumeGainL((TGainType) newGain);
break;
}
case EVolumeBoostDown:
{
TGainType currentGain = (TGainType) iSettings.iGainType;
TInt newGain = currentGain - 1;
if (newGain>=EMinus24dB)
SetVolumeGainL((TGainType) newGain);
break;
}
#endif
#if defined(SERIES60)
case EAknSoftkeyBack:
#endif
case EEikCmdExit:
{
// Only do exit operations if we have actually finished starting up
if (iStartUpState == EStartUpComplete)
{
HandleCommandL(EOggStop);
WriteIniFile();
}
Exit();
break;
}
}
}
void
COggPlayAppUi::PlaySelect()
{
TInt idx = iAppView->GetSelectedIndex();
if (iViewBy==ETop) {
SelectNextView();
return;
}
if (iAppView->GetItemType(idx)==COggListBox::EBack) {
// the back item was selected: show the previous view
SelectPreviousView();
return;
}
#ifdef PLAYLIST_SUPPORT
if (iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder || iViewBy == EPlayList)
#else
if (iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder)
#endif
{
SelectNextView();
return;
}
if (iViewBy==ETitle || iViewBy==EFileName) {
if ( (iOggPlayback->State()==CAbsPlayback::EPaused) &&
(iSongList->IsSelectedFromListBoxCurrentlyPlaying() ) )
{
iOggPlayback->Resume();
#if !defined(DELAY_AUDIO_STREAMING_START)
iAppView->Update();
UpdateSoftkeys();
#endif
return;
}
if ((iOggPlayback->State()==CAbsPlayback::EPaused) || (iOggPlayback->State()==CAbsPlayback::EPlaying))
{
iOggPlayback->Stop();
UpdateSoftkeys();
}
iSongList->SetPlayingFromListBox(idx);
if (iOggPlayback->Open(iSongList->GetPlaying())==KErrNone)
{
iOggPlayback->SetVolume(iVolume);
iOggPlayback->Play();
#if !defined(DELAY_AUDIO_STREAMING_START)
iAppView->SetTime(iOggPlayback->Time());
iAppView->Update();
UpdateSoftkeys();
#endif
} else {
iSongList->SetPlayingFromListBox(ENoFileSelected);
UpdateSoftkeys();
}
}
return;
}
void COggPlayAppUi::PauseResume()
{
if (iOggPlayback->State()==CAbsPlayback::EPlaying)
{
iOggPlayback->Pause();
iAppView->Update();
UpdateSoftkeys();
}
else if (iOggPlayback->State()==CAbsPlayback::EPaused)
{
iOggPlayback->Resume();
#if !defined(DELAY_AUDIO_STREAMING_START)
iAppView->Update();
UpdateSoftkeys();
#endif
}
else
PlaySelect();
}
void COggPlayAppUi::Pause()
{
if (iOggPlayback->State()==CAbsPlayback::EPlaying)
{
iOggPlayback->Pause();
iAppView->Update();
UpdateSoftkeys();
}
}
void COggPlayAppUi::Stop()
{
if ((iOggPlayback->State()==CAbsPlayback::EPlaying) || (iOggPlayback->State()==CAbsPlayback::EPaused))
{
iOggPlayback->Stop();
UpdateSoftkeys();
iSongList->SetPlayingFromListBox(ENoFileSelected); // calls iAppview->Update
}
}
void
COggPlayAppUi::SelectPreviousView()
{
if(iViewHistoryStack.Count()==0) return;
TInt previousListboxLine = (TInt&) (iViewHistoryStack[iViewHistoryStack.Count()-1]);
iViewHistoryStack.Remove(iViewHistoryStack.Count()-1);
const TInt previousView= iAppView->GetViewName(0);
if (previousView==ETop) {
//iViewBy= ETop;
TBuf<16> dummy;
iAppView->FillView(ETop, ETop, dummy);
}
else
HandleCommandL(EOggViewByTitle+previousView);
// Select the entry which were left.
iAppView->SelectItem(previousListboxLine);
return;
}
void
COggPlayAppUi::SelectNextView()
{
int idx = iAppView->GetSelectedIndex();
if (iViewBy==ETop) {
#ifdef PLAYLIST_SUPPORT
if (idx>=ETitle && idx<=EPlayList){
#else
if (idx>=ETitle && idx<=EFileName){
#endif
iViewHistoryStack.Append(idx);
HandleCommandL(EOggViewByTitle+idx);
}
return;
}
#ifdef PLAYLIST_SUPPORT
if (!(iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder || iViewBy==EPlayList)) return;
#else
if (!(iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder)) return;
#endif
if (iAppView->GetItemType(idx) == COggListBox::EBack)
return;
iViewHistoryStack.Append(idx);
TBuf<128> filter;
iAppView->GetFilterData(idx, filter);
if ((iViewBy==EPlayList) || (iViewBy==ESubFolder))
iAppView->FillView(EFileName, iViewBy, filter);
else
iAppView->FillView(ETitle, iViewBy, filter);
}
void
COggPlayAppUi::ShowFileInfo()
{
TBool songPlaying = iSongList->AnySongPlaying();
TInt selectedIndex = iAppView->GetSelectedIndex();
if (!songPlaying && (selectedIndex<0)) return;
COggListBox::TItemTypes itemType;
if (!songPlaying) {
// no song is playing, show info for selected song if possible
itemType = iAppView->GetItemType(selectedIndex);
if (itemType==COggListBox::EBack) return;
if (iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder || iViewBy==ETop) return;
if (itemType != COggListBox::EPlayList)
{
const TDesC& fileName = iAppView->GetFileName(selectedIndex);
if (iOggPlayback->Info(fileName)!=KErrNone)
return;
}
}
else
itemType = (iSongList->GetPlayingFile()->FileType() == TOggFile::EPlayList) ? COggListBox::EPlayList : COggListBox::EFileName;
if (itemType == COggListBox::EPlayList)
{
TOggPlayList* playList;
if (!songPlaying)
playList = (TOggPlayList*) iAppView->GetFile(selectedIndex);
else
playList = (TOggPlayList*) iSongList->GetPlayingFile();
COggPlayListInfoDialog *d = new(ELeave) COggPlayListInfoDialog();
const TDesC& fileName = *(playList->iFileName);
d->SetFileName(fileName);
d->SetFileSize(FileSize(fileName));
d->SetPlayListEntries(playList->Count());
d->ExecuteLD(R_DIALOG_PLAYLIST_INFO);
}
else
{
TInt fileSize;
if (songPlaying)
fileSize = iOggPlayback->FileSize();
else
fileSize = FileSize(iOggPlayback->FileName());
COggInfoDialog *d = new(ELeave) COggInfoDialog();
d->SetFileName(iOggPlayback->FileName());
d->SetRate(iOggPlayback->Rate());
d->SetChannels(iOggPlayback->Channels());
d->SetFileSize(fileSize);
#if defined(SERIES60V3)
d->SetTime(iOggPlayback->Time());
#else
d->SetTime(iOggPlayback->Time().GetTInt());
#endif
d->SetBitRate(iOggPlayback->BitRate()/1000);
if (!songPlaying) iOggPlayback->ClearComments();
d->ExecuteLD(R_DIALOG_INFO);
}
}
void
COggPlayAppUi::NextSong()
{
// This function guarantees that a next song will be played.
// This is important since it is also being used if an alarm is triggered.
// If neccessary the current view will be switched.
if ( iSongList->AnySongPlaying() )
{
// if a song is currently playing, find and play the next song
const TDesC &songName = iSongList->GetNextSong();
#ifndef PLUGIN_SYSTEM
iOggPlayback->Stop();
#endif
if (songName.Length()>0 && iOggPlayback->Open(songName)==KErrNone)
{
iOggPlayback->Play();
#if !defined(DELAY_AUDIO_STREAMING_START)
iAppView->SetTime(iOggPlayback->Time());
UpdateSoftkeys();
iAppView->Update();
#endif
} else {
iSongList->SetPlayingFromListBox(ENoFileSelected);
HandleCommandL(EOggStop);
}
} else {
// Switch view
if (iViewBy==ETop) {
HandleCommandL(EOggPlay); // select the current category
HandleCommandL(EOggPlay); // select the 1st song in that category
HandleCommandL(EOggPlay); // play it!
} else if (iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder) {
HandleCommandL(EOggPlay); // select the 1st song in the current category
HandleCommandL(EOggPlay); // play it!
} else {
// if no song is playing, play the currently selected song
if (iAppView->GetItemType(iAppView->GetSelectedIndex())==COggListBox::EBack) iAppView->SelectItem(1);
HandleCommandL(EOggPlay); // play it!
}
}
}
void
COggPlayAppUi::PreviousSong()
{
if ( iSongList->AnySongPlaying() )
{
// if a song is currently playing, find and play the previous song
const TDesC &songName = iSongList->GetPreviousSong();
#ifndef PLUGIN_SYSTEM
iOggPlayback->Stop();
#endif
if (songName.Length()>0 && iOggPlayback->Open(songName)==KErrNone)
{
iOggPlayback->Play();
#if !defined(DELAY_AUDIO_STREAMING_START)
iAppView->SetTime(iOggPlayback->Time());
UpdateSoftkeys();
iAppView->Update();
#endif
} else {
iSongList->SetPlayingFromListBox(ENoFileSelected);
HandleCommandL(EOggStop);
}
}
else
{
if (iViewBy==ETop) {
HandleCommandL(EOggPlay); // select the current category
HandleCommandL(EOggPlay); // select the 1st song in that category
HandleCommandL(EOggPlay); // play it!
} else if (iViewBy==EAlbum || iViewBy==EArtist || iViewBy==EGenre || iViewBy==ESubFolder) {
HandleCommandL(EOggPlay); // select the 1st song in the current category
HandleCommandL(EOggPlay); // play it!
} else {
// if no song is playing, play the currently selected song
if (iAppView->GetItemType(iAppView->GetSelectedIndex())==COggListBox::EBack) iAppView->SelectItem(1);
HandleCommandL(EOggPlay); // play it!
}
}
}
void
COggPlayAppUi::DynInitMenuPaneL(int aMenuId, CEikMenuPane* aMenuPane)
{
if (aMenuId==R_FILE_MENU)
{
#if defined(SERIES60)
// If the splash screen is still visible we can't do anything other than exit
if (iStartUpState != EStartUpComplete)
{
aMenuPane->DeleteBetweenMenuItems(0, 4);
return;
}
#endif
// "Repeat" on/off entry, UIQ uses check box, Series 60 uses variable argument string.
#if defined(UIQ)
if (iSettings.iRepeat)
aMenuPane->SetItemButtonState(EOggRepeat, EEikMenuItemSymbolOn);
// UIQ_? for the random stuff
#elif defined(SERIES60)
// FIXIT - Should perhaps be in the options menu instead ??
TBuf<50> buf;
iEikonEnv->ReadResource(buf, iSettings.iRandom ? R_OGG_RANDOM_OFF : R_OGG_RANDOM_ON);
aMenuPane->SetItemTextL(EOggShuffle, buf);
#endif
TBool isSongList= ((iViewBy==ETitle) || (iViewBy==EFileName) || (iViewBy == EPlayList));
aMenuPane->SetItemDimmed(EOggInfo , (!iSongList->AnySongPlaying()) && (iAppView->GetSelectedIndex()<0 || !isSongList));
}
if (aMenuId==R_SKIN_MENU)
{
for (TInt i=0; i<iSkins->Count(); i++)
{
CEikMenuPaneItem::SData item;
item.iText.Copy((*iSkins)[i]);
item.iText.SetLength(item.iText.Length()-4);
item.iCommandId= EOggSkinOne+i;
item.iCascadeId= 0;
item.iFlags= 0;
aMenuPane->AddMenuItemL(item);
}
}
#if defined(UIQ)
if (aMenuId==R_POPUP_MENU)
{
if (iSettings.iRepeat) aMenuPane->SetItemButtonState(EOggRepeat, EEikMenuItemSymbolOn);
aMenuPane->SetItemDimmed(EOggStop, !iAppView->CanStop());
aMenuPane->SetItemDimmed(EOggPlay, !iAppView->CanPlay());
aMenuPane->SetItemDimmed(EOggPauseResume, !iAppView->CanPause());
}
#endif
}
void COggPlayAppUi::FindSkins()
{
iSkins->Reset();
CDirScan* ds = CDirScan::NewLC(iCoeEnv->FsSession());
TRAPD(err,ds->SetScanDataL(iSkinFileDir,KEntryAttNormal,ESortByName|EAscending,CDirScan::EScanDownTree));
if (err!=KErrNone) {
//_LIT(KS,"Error in FindSkins-SetScanDataL");
//OGGLOG.WriteFormat(KS);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -