📄 oggplayappview.cpp
字号:
__ASSERT_ALWAYS ( type == COggListBox::EBack,
User::Panic(_L("GetViewName called with wrong argument"),0 ) );
return (COggPlayAppUi::TViews) GetValueFromTextLine(idx);
}
void
COggPlayAppView::GetFilterData(TInt idx, TDes & aData)
{
COggListBox::TItemTypes type = GetItemType(idx) ;
#ifdef PLAYLIST_SUPPORT
__ASSERT_ALWAYS ( ( (type == COggListBox::EAlbum) || (type == COggListBox::EArtist) || (type ==COggListBox::EGenre) || (type == COggListBox::ESubFolder) || (type == COggListBox::EPlayList) || (type == COggListBox::ETitle) || (type == COggListBox::EFileName) ),
User::Panic(_L("COggPlayAppView::GetFilterData called with wrong argument"),0 ) );
#else
__ASSERT_ALWAYS ( ( (type == COggListBox::EAlbum) || (type == COggListBox::EArtist) || (type ==COggListBox::EGenre) || (type == COggListBox::ESubFolder) ),
User::Panic(_L("COggPlayAppView::GetFilterData called with wrong argument"),0 ) );
#endif
CDesCArray* arr= GetTextArray();
__ASSERT_ALWAYS ( arr,
User::Panic(_L("COggPlayAppView::GetFilterData Array Not found"),0 ) );
TPtrC sel,msel;
if(idx >= 0 && idx < arr->Count())
{
sel.Set((*arr)[idx]);
TextUtils::ColumnText(msel, 2, &sel );
}
aData.Copy(msel);
return ;
}
COggListBox::TItemTypes
COggPlayAppView::GetItemType(TInt idx)
{
// TODO: Panic if we can't get the item type (returning COggListBox::ETitle isn't really the right thing to do)
CDesCArray* arr= GetTextArray();
if (!arr)
return COggListBox::ETitle;
TPtrC sel,msel;
if(idx >= 0 && idx < arr->Count()) {
sel.Set((*arr)[idx]);
TextUtils::ColumnText(msel, 0, &sel);
TLex parse(msel);
TInt atype(COggListBox::ETitle);
parse.Val(atype);
return (COggListBox::TItemTypes) atype;
}
return COggListBox::ETitle;
}
void
COggPlayAppView::SelectItem(TInt idx)
{
iSelected= idx;
if (iListBox[iMode]) {
iSelected = iListBox[iMode]->SetCurrentItemIndex(idx);
iCanvas[iMode]->Refresh();
}
}
void
COggPlayAppView::SelectFile(TOggFile* aFile)
{
TInt found = -1;
for (TInt i=0; i<GetTextArray()->Count(); i++)
{
if( HasAFileName(i) )
{
if (GetFile(i) == aFile)
{
// A match !
found = i;
break;
}
}
}
if (found != -1)
{
// If found, select it.
iSelected= found;
if (iListBox[iMode]) {
iSelected = iListBox[iMode]->SetCurrentItemIndex(found);
}
} // Otherwise, do nothing
}
TInt
COggPlayAppView::GetSelectedIndex()
{
return iSelected;
/*
if (iListBox[iMode]) return iListBox[iMode]->CurrentItemIndex();
TInt otherMode= (iMode+1)%2;
if (iListBox[otherMode]) return iListBox[otherMode]->CurrentItemIndex();
return -1;
*/
}
CDesCArray*
COggPlayAppView::GetTextArray()
{
return iTextArray;
}
void
COggPlayAppView::ListBoxPageDown()
{
TInt index = iListBox[iMode]->CurrentItemIndex();
if( index != iListBox[iMode]->CountText() - 1)
SelectItem(index + iListBox[iMode]->NofVisibleLines() - 1);
}
void
COggPlayAppView::ListBoxPageUp()
{
TInt index = iListBox[iMode]->CurrentItemIndex();
if(index != 0)
SelectItem(index - iListBox[iMode]->NofVisibleLines() + 1);
}
void
COggPlayAppView::SetTime(TInt64 aTime)
{
#if defined(SERIES60V3)
if (iPosition[iMode]) iPosition[iMode]->SetMaxValue(aTime);
#else
if (iPosition[iMode]) iPosition[iMode]->SetMaxValue(aTime.GetTInt());
#endif
}
void
COggPlayAppView::UpdateRepeat()
{
if (iApp->iSettings.iRepeat) {
if (iRepeatIcon[iMode]) iRepeatIcon[iMode]->Show();
if (iRepeatButton[iMode]) iRepeatButton[iMode]->SetState(1);
} else {
if (iRepeatIcon[iMode]) iRepeatIcon[iMode]->Hide();
if (iRepeatButton[iMode]) iRepeatButton[iMode]->SetState(0);
}
}
void
COggPlayAppView::UpdateRandom()
{
if (iApp->iSettings.iRandom) {
if (iRandomIcon[iMode]) iRandomIcon[iMode]->Show();
if (iRandomButton[iMode]) iRandomButton[iMode]->SetState(1);
} else {
if (iRandomIcon[iMode]) iRandomIcon[iMode]->Hide();
if (iRandomButton[iMode]) iRandomButton[iMode]->SetState(0);
}
}
TInt
COggPlayAppView::CallBack(TAny* aPtr)
{
COggPlayAppView* self = (COggPlayAppView*) aPtr;
self->HandleCallBack();
return 1;
}
void COggPlayAppView::HandleCallBack()
{
if (iAnalyzer[iMode] && iAnalyzer[iMode]->Style()>0)
{
if (iApp->iOggPlayback->State()==CAbsPlayback::EPlaying)
{
#ifdef MDCT_FREQ_ANALYSER
iAnalyzer[iMode]->RenderWaveformFromMDCT(
iApp->iOggPlayback->GetFrequencyBins() );
#else /* !MDCT_FREQ_ANALYSER */
#if defined(SERIES60)
iAnalyzer[iMode]->RenderWaveform((short int*)iApp->iOggPlayback->GetDataChunk());
#else
iAnalyzer[iMode]->RenderWaveform((short int[2][512])iApp->iOggPlayback->GetDataChunk());
#endif
#endif /* MDCT_FREQ_ANALYSER */
}
}
if (iCycleFrequencyCounter % 2)
{
#if defined(SERIES60V3)
if (iPosition[iMode] && iPosChanged<0)
iPosition[iMode]->SetValue(iApp->iOggPlayback->Position());
#else
if (iPosition[iMode] && iPosChanged<0)
iPosition[iMode]->SetValue(iApp->iOggPlayback->Position().GetTInt());
#endif
iCanvas[iMode]->CycleLowFrequencyControls();
}
iCanvas[iMode]->CycleHighFrequencyControls();
iCanvas[iMode]->Refresh();
iCycleFrequencyCounter--;
if (iCycleFrequencyCounter == 0)
{
// 1Hz controls
iCycleFrequencyCounter = KOggControlFreq;
// Update the clock
UpdateClock();
// Update the song position
if (iApp->iOggPlayback->State() == CAbsPlayback::EPlaying)
UpdateSongPosition();
}
}
void COggPlayAppView::RestartCallBack()
{
if (!iTimer->IsActive())
iTimer->Start(TTimeIntervalMicroSeconds32(KCallBackPeriod), TTimeIntervalMicroSeconds32(KCallBackPeriod), *iCallBack);
}
void COggPlayAppView::StopCallBack()
{
iTimer->Cancel();
}
TInt COggPlayAppView::AlarmCallBack(TAny* aPtr)
{
COggPlayAppView* self = (COggPlayAppView*) aPtr;
self->HandleAlarmCallBack();
return 1;
}
TInt COggPlayAppView::AlarmErrorCallBack(TAny* aPtr)
{
// Our alarm has been cancelled / aborted, probably because the user changed the system time
COggPlayAppView* self = (COggPlayAppView*) aPtr;
self->SetAlarm();
return 1;
}
void COggPlayAppView::HandleAlarmCallBack()
{
// Set off an alarm when the alarm time has been reached
if (iApp->iOggPlayback->State() != CAbsPlayback::EPlaying)
{
// Set the volume and volume boost
iApp->iVolume = (iApp->iSettings.iAlarmVolume * KMaxVolume)/10;
iApp->SetVolumeGainL((TGainType) iApp->iSettings.iAlarmGain);
// Play the next song or unpause the current one
if (iApp->iOggPlayback->State() == CAbsPlayback::EPaused)
iApp->PauseResume();
else
iApp->NextSong();
}
// Reset the alarm
#ifndef UIQ
#if defined(SERIES60)
CAknQueryDialog* snoozeDlg = CAknQueryDialog::NewL();
#else
CEikDialog* snoozeDlg = new(ELeave) CEikDialog;
#endif
TInt snoozeCmd = snoozeDlg->ExecuteLD(R_OGGPLAY_SNOOZE_DLG);
if (snoozeCmd == EOggButtonSnooze)
{
// Pause playing
iApp->Pause();
// Set the alarm to fire again in five minutes
SnoozeAlarm();
}
else if (snoozeCmd == EOggButtonCancel)
{
// Stop playing
iApp->Stop();
// Set the alarm to fire again tomorrow
SetAlarm();
}
else
#endif
{
// Set the alarm to fire again tomorrow
SetAlarm();
}
}
void COggPlayAppView::Invalidate()
{
iCanvas[iMode]->Invalidate();
}
void COggPlayAppView::InitView()
{
// fill the list box with some initial content:
if (!iOggFiles->ReadDb(iApp->iDbFileName, iCoeEnv->FsSession()))
{
iOggFiles->CreateDb(iCoeEnv->FsSession());
iOggFiles->WriteDbL(iApp->iDbFileName, iCoeEnv->FsSession());
}
const TBuf<16> dummy;
FillView(COggPlayAppUi::ETop, COggPlayAppUi::ETop, dummy);
if (iAnalyzer[0]) iAnalyzer[0]->SetStyle(iApp->iAnalyzerState);
if (iAnalyzer[1]) iAnalyzer[1]->SetStyle(iApp->iAnalyzerState);
}
void COggPlayAppView::FillView(COggPlayAppUi::TViews theNewView, COggPlayAppUi::TViews thePreviousView, const TDesC& aSelection)
{
TBuf<32> buf;
TBuf<16> dummy;
TBuf<256> back;
if (theNewView==COggPlayAppUi::ETop) {
TInt dummy = -1;
GetTextArray()->Reset();
iEikonEnv->ReadResource(buf, R_OGG_STRING_6);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::ETitle, buf, dummy);
iEikonEnv->ReadResource(buf, R_OGG_STRING_7);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::EAlbum, buf, dummy);
iEikonEnv->ReadResource(buf, R_OGG_STRING_8);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::EArtist, buf, dummy);
iEikonEnv->ReadResource(buf, R_OGG_STRING_9);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::EGenre, buf, dummy);
iEikonEnv->ReadResource(buf, R_OGG_STRING_10);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::ESubFolder, buf, dummy);
iEikonEnv->ReadResource(buf, R_OGG_STRING_11);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::EFileName, buf, dummy);
#ifdef PLAYLIST_SUPPORT
iEikonEnv->ReadResource(buf, R_OGG_STRING_12);
TOggFiles::AppendLine(*GetTextArray(), COggListBox::EPlayList, buf, dummy);
#endif
}
else if (thePreviousView==COggPlayAppUi::ETop) {
switch (theNewView) {
case COggPlayAppUi::ETitle: iOggFiles->FillTitles(*GetTextArray(), dummy, dummy, dummy, dummy); break;
case COggPlayAppUi::EAlbum: iOggFiles->FillAlbums(*GetTextArray(), dummy, dummy); break;
case COggPlayAppUi::EArtist: iOggFiles->FillArtists(*GetTextArray(), dummy); break;
case COggPlayAppUi::EGenre: iOggFiles->FillGenres(*GetTextArray(), dummy, dummy, dummy); break;
case COggPlayAppUi::ESubFolder: iOggFiles->FillSubFolders(*GetTextArray()); break;
case COggPlayAppUi::EFileName: iOggFiles->FillFileNames(*GetTextArray(), dummy, dummy, dummy, dummy); break;
#ifdef PLAYLIST_SUPPORT
case COggPlayAppUi::EPlayList: iOggFiles->FillPlayLists(*GetTextArray()); break;
#endif
default: break;
}
back.Num((TInt) COggListBox::EBack);
back.Append(KColumnListSeparator);
#if defined(UIQ)
back.Append(_L(".."));
#else
iEikonEnv->ReadResource(buf, R_OGG_BACK_DIR);
back.Append(buf);
#endif
back.Append(KColumnListSeparator);
back.AppendNum((TInt)thePreviousView);
GetTextArray()->InsertL(0,back);
}
else {
switch (thePreviousView) {
case COggPlayAppUi::ETitle : iOggFiles->FillTitles(*GetTextArray(), dummy, dummy, dummy, dummy); break;
case COggPlayAppUi::EAlbum : iOggFiles->FillTitles(*GetTextArray(), aSelection, dummy, dummy, dummy); break;
case COggPlayAppUi::EArtist : iOggFiles->FillTitles(*GetTextArray(), dummy, aSelection, dummy, dummy); break;
case COggPlayAppUi::EGenre : iOggFiles->FillTitles(*GetTextArray(), dummy, dummy, aSelection, dummy); break;
case COggPlayAppUi::ESubFolder: iOggFiles->FillFileNames(*GetTextArray(), dummy, dummy, dummy, aSelection); break;
case COggPlayAppUi::EFileName : iOggFiles->FillFileNames(*GetTextArray(), dummy, dummy, dummy, dummy); break;
#ifdef PLAYLIST_SUPPORT
case COggPlayAppUi::EPlayList : iOggFiles->FillPlayList(*GetTextArray(), aSelection); break;
#endif
default: break;
}
if (aSelection.Length()>0) {
back.Num((TInt) COggListBox::EBack);
back.Append(KColumnListSeparator);
#if defined(UIQ)
back.Append(_L(".."));
#else
iEikonEnv->ReadResource(buf, R_OGG_BACK_DIR);
back.Append(buf);
#endif
back.Append(KColumnListSeparator);
back.AppendNum((TInt)thePreviousView);
GetTextArray()->InsertL(0,back);
}
}
iApp->iViewBy = theNewView;
UpdateListbox();
// Choose the selected item.
// If random is turned off: First of the list, unless it is a "back" icon, in that case 2nd
// If random is turned on:
// When playing a file, do as if random wasn't turned on
// If not playing a file, choose a random file
if (theNewView == COggPlayAppUi::ETop)
{
SelectItem(0);
} else
{
if (iApp->iSettings.iRandom)
{
if ( iApp->iSongList->AnySongPlaying() )
{
// When a song has been playing, give full power to the user
// Do not select a random value.
SelectItem(1);
} else
{
// Select a random value for the first index
#if defined(SERIES60V3)
TInt64 rnd64 = Math::Random();
TInt64 maxInt64 = MAKE_TINT64(1, 0);
#else
TInt64 rnd64 = TInt64(0, Math::Random());
TInt64 maxInt64 = TInt64(1, 0);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -