📄 oggplayappview.cpp
字号:
iApp->iOggPlayback->SetVolume(iApp->iVolume);
UpdateVolume();
} else { // not playing, i.e. stopped or paused
if (scanCode==EOggDown || scanCode==EOggLeft) {
iApp->SelectPreviousView();
} else if (scanCode==EOggDown || scanCode==EOggRight) {
if( HasAFileName(index) )
iApp->HandleCommandL(EOggPlay);
else
iApp->SelectNextView();
}
}
return EKeyWasConsumed;
}
}
}
if(code == EOggConfirm) {
if(!iFocusControlsPresent) {
if (iApp->iOggPlayback->State()==CAbsPlayback::EPlaying ||
iApp->iOggPlayback->State()==CAbsPlayback::EPaused) {
if (iApp->iSongList->IsSelectedFromListBoxCurrentlyPlaying() && ((iApp->iViewBy==COggPlayAppUi::ETitle) || (iApp->iViewBy==COggPlayAppUi::EFileName)))
// Event on the current active file
iApp->HandleCommandL(EOggPauseResume);
else
iApp->HandleCommandL(EOggPlay);
}
else
// Event without any active files
iApp->HandleCommandL(EOggPlay);
} else if(c==iPlayButton[iMode]) {
// manually move focus to pause button
c->SetFocus(EFalse);
do {
iFocusControlsIter++;
if(!iFocusControlsIter) iFocusControlsIter.SetToFirst();
c=iFocusControlsIter;
} while (c!=iPauseButton[iMode]);
c->SetFocus(ETrue);
iApp->HandleCommandL(EOggPauseResume);
} else if (c==iPauseButton[iMode]) {
c->SetFocus(EFalse);
do {
iFocusControlsIter++;
if(!iFocusControlsIter) iFocusControlsIter.SetToFirst();
c=iFocusControlsIter;
} while (c!=iPlayButton[iMode]);
c->SetFocus(ETrue);
iApp->HandleCommandL(EOggPauseResume);
} else if(c==iStopButton[iMode]) {
iApp->HandleCommandL(EOggStop);
} else if (iApp->iOggPlayback->State()==CAbsPlayback::EPlaying ||
iApp->iOggPlayback->State()==CAbsPlayback::EPaused)
iApp->HandleCommandL(EOggStop);
else iApp->HandleCommandL(EOggPlay);
return EKeyWasConsumed;
}
#if defined(SERIES60)
// S60 User Hotkeys
switch(COggUserHotkeysControl::Hotkey(aKeyEvent,aType,&iApp->iSettings)) {
case TOggplaySettings::EFastForward : {
TInt64 pos=iApp->iOggPlayback->Position() + KFfRwdStep;
iApp->iOggPlayback->SetPosition(pos);
#if defined(SERIES60V3)
iPosition[iMode]->SetValue(pos);
#else
iPosition[iMode]->SetValue(pos.GetTInt());
#endif
UpdateSongPosition();
iCanvas[iMode]->Refresh();
return EKeyWasConsumed;
}
case TOggplaySettings::ERewind : {
TInt64 pos=iApp->iOggPlayback->Position() - KFfRwdStep;
iApp->iOggPlayback->SetPosition(pos);
#if defined(SERIES60V3)
iPosition[iMode]->SetValue(pos);
#else
iPosition[iMode]->SetValue(pos.GetTInt());
#endif
UpdateSongPosition();
iCanvas[iMode]->Refresh();
return EKeyWasConsumed;
}
case TOggplaySettings::EPageDown : {
ListBoxPageDown();
return EKeyWasConsumed;
}
case TOggplaySettings::EPageUp : {
ListBoxPageUp();
return EKeyWasConsumed;
}
case TOggplaySettings::ENextSong : {
iApp->NextSong();
return EKeyWasConsumed;
}
case TOggplaySettings::EPreviousSong : {
iApp->PreviousSong();
return EKeyWasConsumed;
}
case TOggplaySettings::EPauseResume : {
iApp->PauseResume();
return EKeyWasConsumed;
}
case TOggplaySettings::EPlay : {
iApp->HandleCommandL(EOggPlay);
return EKeyWasConsumed;
}
case TOggplaySettings::EPause : {
iApp->HandleCommandL(EUserPauseCBA); // well..
return EKeyWasConsumed;
}
case TOggplaySettings::EStop : {
iApp->HandleCommandL(EOggStop);
return EKeyWasConsumed;
}
case TOggplaySettings::EKeylock : {
if( aKeyEvent.iRepeats > 0 )
{
RAknKeyLock keyLock;
keyLock.Connect ();
keyLock.EnableKeyLock() ;
keyLock.Close() ;
}
return EKeyWasConsumed;
}
case TOggplaySettings::EVolumeBoostUp : {
TGainType currentGain = (TGainType) iApp->iSettings.iGainType;
TInt newGain = currentGain + 1;
if (newGain<=EStatic12dB)
iApp->SetVolumeGainL((TGainType) newGain);
return EKeyWasConsumed;
}
case TOggplaySettings::EVolumeBoostDown : {
TGainType currentGain = (TGainType) iApp->iSettings.iGainType;
TInt newGain = currentGain - 1;
if (newGain>=EMinus24dB)
iApp->SetVolumeGainL((TGainType) newGain);
return EKeyWasConsumed;
}
default :
break;
}
#endif
if (code>0) {
if (aKeyEvent.iScanCode==EStdKeyDeviceD) { iApp->NextSong(); return EKeyWasConsumed; } // jog dial up
else if (aKeyEvent.iScanCode==EStdKeyDeviceE) { iApp->PreviousSong(); return EKeyWasConsumed; } // jog dial down
else if (aKeyEvent.iScanCode==167) { AppToForeground(EFalse); return EKeyWasConsumed; } // back key <-
else if (aKeyEvent.iScanCode==174) { iApp->HandleCommandL(EOggStop); return EKeyWasConsumed; } // "C" key
//else if (aKeyEvent.iScanCode==173) { iApp->HandleCommandL(EOggShuffle); return EKeyWasConsumed; }// menu button
else if (aKeyEvent.iScanCode==173) {
} else if (aKeyEvent.iScanCode==133) { // "*"
if (iTitle[iMode]) iTitle[iMode]->ScrollNow();
if (iAlbum[iMode]) iAlbum[iMode]->ScrollNow();
if (iArtist[iMode]) iArtist[iMode]->ScrollNow();
if (iGenre[iMode]) iGenre[iMode]->ScrollNow();
return EKeyWasConsumed;
}
else if (aKeyEvent.iScanCode==127) { // "#"
iApp->ToggleRepeat();
return EKeyWasConsumed;
}
// 48..57 == "0"..."9"
// 172 jog dial press
// 179 == OK
// this is what's being sent when closing through taskswitcher
// couldn't find any documentation on this.
if(code==EStdKeyNumLock) {
iApp->HandleCommandL(EEikCmdExit);
return EKeyWasConsumed;
}
}
return EKeyWasNotConsumed;
#else // UIQ keyhandling
#if !defined( MOTOROLA )
enum EOggKeys {
EOggConfirm=EQuartzKeyConfirm,
};
enum EOggScancodes {
EOggUp=EStdQuartzKeyTwoWayUp,
EOggDown=EStdQuartzKeyTwoWayDown
};
TInt code = aKeyEvent.iCode;
TInt modifiers= aKeyEvent.iModifiers & EAllStdModifiers;
TInt iHotkey = ((COggPlayAppUi *)iEikonEnv->EikAppUi())->iHotkey;
if (iHotkey && aType == EEventKey &&
code == keycodes[iHotkey-1].code && modifiers==keycodes[iHotkey-1].mask) {
iApp->ActivateOggViewL();
return EKeyWasConsumed;
}
if(code == EOggConfirm) {
if (IsFlipOpen()) {
if (iApp->iOggPlayback->State()==CAbsPlayback::EPlaying ||
iApp->iOggPlayback->State()==CAbsPlayback::EPaused) iApp->HandleCommandL(EOggStop);
else iApp->HandleCommandL(EOggPlay);
} else {
if (iApp->iOggPlayback->State()==CAbsPlayback::EPlaying ||
iApp->iOggPlayback->State()==CAbsPlayback::EPaused) iApp->HandleCommandL(EOggPauseResume);
else iApp->HandleCommandL(EOggPlay);
}
return EKeyWasConsumed;
}
if (code>0) {
if (aKeyEvent.iScanCode==EStdKeyDeviceD) { iApp->NextSong(); return EKeyWasConsumed; } // jog dial up
else if (aKeyEvent.iScanCode==EStdKeyDeviceE) { iApp->PreviousSong(); return EKeyWasConsumed; } // jog dial down
else if (aKeyEvent.iScanCode==167) { AppToForeground(EFalse); return EKeyWasConsumed; } // back key <-
else if (aKeyEvent.iScanCode==174) { iApp->HandleCommandL(EOggStop); return EKeyWasConsumed; } // "C" key
//else if (aKeyEvent.iScanCode==173) { iApp->HandleCommandL(EOggShuffle); return EKeyWasConsumed; }// menu button
else if (aKeyEvent.iScanCode==173) {
iApp->LaunchPopupMenuL(R_POPUP_MENU,TPoint(100,100),EPopupTargetTopLeft);
//Invalidate();
//Update();
return EKeyWasConsumed;
} else if (aKeyEvent.iScanCode==133) { // "*"
if (iTitle[iMode]) iTitle[iMode]->ScrollNow();
if (iAlbum[iMode]) iAlbum[iMode]->ScrollNow();
if (iArtist[iMode]) iArtist[iMode]->ScrollNow();
if (iGenre[iMode]) iGenre[iMode]->ScrollNow();
return EKeyWasConsumed;
}
else if (aKeyEvent.iScanCode==127) { // "#"
iApp->ToggleRepeat();
return EKeyWasConsumed;
}
// 48..57 == "0"..."9"
// 172 jog dial press
// 179 == OK
}
if (iApp->iOggPlayback->State()==CAbsPlayback::EPlaying || !IsFlipOpen() ) {
// volume
if (code==0 && aType==EEventKeyDown) {
if (aKeyEvent.iScanCode==EOggUp || aKeyEvent.iScanCode==EOggDown) {
if (aKeyEvent.iScanCode==EOggUp && iApp->iVolume<100) iApp->iVolume+= 5;
if (aKeyEvent.iScanCode==EOggDown && iApp->iVolume>0) iApp->iVolume-= 5;
iApp->iOggPlayback->SetVolume(iApp->iVolume);
UpdateVolume();
return EKeyWasConsumed;
}
}
} else if (iListBox[iMode]) {
// move current index in the list box
if (code==0 && aType==EEventKeyDown) {
TInt idx= iListBox[iMode]->CurrentItemIndex();
if (aKeyEvent.iScanCode==EOggUp && idx>0) {
SelectItem(idx-1);
return EKeyWasConsumed;
}
if (aKeyEvent.iScanCode==EOggDown) {
SelectItem(idx+1);
return EKeyWasConsumed;
}
}
}
return EKeyWasNotConsumed;
#else // defined MOTOROLA
enum EOggKeys
{ EOggConfirm = EQuartzKeyConfirm,
EOggUp = EQuartzKeyFourWayUp,
EOggDown = EQuartzKeyFourWayDown,
EOggLeft = EQuartzKeyFourWayLeft,
EOggRight = EQuartzKeyFourWayRight,
EOggButton1 = EKeyApplicationA,
EOggButton2 = EKeyApplicationB
};
TKeyResponse resp = EKeyWasNotConsumed;
TInt code = aKeyEvent.iCode;
TInt modifiers = aKeyEvent.iModifiers & EAllStdModifiers;
TInt iHotkey = ((COggPlayAppUi *) iEikonEnv->EikAppUi())->iHotkey;
if ( aType == EEventKey )
{
if ( iHotkey &&
code == keycodes[iHotkey-1].code &&
modifiers == keycodes[iHotkey-1].mask )
{
iApp->ActivateOggViewL();
resp = EKeyWasConsumed;
}
else
{
switch ( code )
{
case EOggConfirm:
if ( iApp->iOggPlayback->State() == CAbsPlayback::EPlaying ||
iApp->iOggPlayback->State() == CAbsPlayback::EPaused )
{
iApp->HandleCommandL(EOggStop);
}
else
{
iApp->HandleCommandL(EOggPlay);
}
resp = EKeyWasConsumed;
break;
case EOggUp:
if ( iApp->iOggPlayback->State() != CAbsPlayback::EPlaying &&
iApp->iOggPlayback->State() != CAbsPlayback::EPaused )
{
iApp->HandleCommandL(EOggPlay);
}
resp = EKeyWasConsumed;
break;
case EOggDown:
if ( iApp->iOggPlayback->State() == CAbsPlayback::EPlaying ||
iApp->iOggPlayback->State() == CAbsPlayback::EPaused )
{
iApp->HandleCommandL(EOggStop);
}
resp = EKeyWasConsumed;
break;
case EOggLeft:
iApp->PreviousSong();
resp = EKeyWasConsumed;
break;
case EOggRight:
iApp->NextSong();
resp = EKeyWasConsumed;
break;
case EOggButton1:
if (iTitle[iMode]) iTitle[iMode]->ScrollNow();
if (iAlbum[iMode]) iAlbum[iMode]->ScrollNow();
if (iArtist[iMode]) iArtist[iMode]->ScrollNow();
if (iGenre[iMode]) iGenre[iMode]->ScrollNow();
resp = EKeyWasConsumed;
break;
case EOggButton2:
iApp->LaunchPopupMenuL(R_POPUP_MENU,TPoint(100,100),EPopupTargetTopLeft);
resp = EKeyWasConsumed;
break;
default:
break;
}
}
}
return ( resp );
#endif
#endif // UIQ keyhandling
}
void
COggPlayAppView::OggControlEvent(COggControl* c, TInt aEventType, TInt /*aValue*/)
{
if (c==iListBox[iMode]) {
if (aEventType==1) {
iSelected= iListBox[iMode]->CurrentItemIndex();
UpdateControls(); // the current item index changed
}
if (aEventType==2) iApp->HandleCommandL(EOggPlay); // an item was selected (by tipping on it)
}
if (c==iPlayButton[iMode]) {
if (iApp->iOggPlayback->State()==CAbsPlayback::EPaused)
iApp->HandleCommandL(EOggPauseResume);
else
iApp->HandleCommandL(EOggPlay);
}
if (c==iPauseButton[iMode]) iApp->HandleCommandL(EOggPauseResume);
if (c==iStopButton[iMode]) iApp->HandleCommandL(EOggStop);
if (c==iNextSongButton[iMode]) iApp->NextSong();
if (c==iPrevSongButton[iMode]) iApp->PreviousSong();
if (c==iRepeatButton[iMode]) iApp->ToggleRepeat();
if (c==iRandomButton[iMode]) iApp->ToggleRandom();
}
void
COggPlayAppView::OggPointerEvent(COggControl* c, const TPointerEvent& p)
{
if (c==iPosition[iMode]) {
if (p.iType==TPointerEvent::EButton1Down || p.iType==TPointerEvent::EDrag) {
iPosChanged= iPosition[iMode]->CurrentValue();
}
if (p.iType==TPointerEvent::EButton1Up) {
iApp->iOggPlayback->SetPosition(TInt64(iPosChanged));
iPosChanged= -1;
}
}
if (c==iVolume[iMode]) {
iApp->iVolume= iVolume[iMode]->CurrentValue();
iApp->iOggPlayback->SetVolume(iApp->iVolume);
}
if (c==iAnalyzer[iMode]) {
iApp->iAnalyzerState= iAnalyzer[iMode]->Style();
}
}
void COggPlayAppView::AddControlToFocusList(COggControl* c) {
COggControl* currentitem = iFocusControlsIter;
if (currentitem) {
iFocusControlsPresent=ETrue;
c->iDlink.Enque(¤titem->iDlink);
iFocusControlsIter.Set(*c);
} else {
iFocusControlsHeader.AddFirst(*c);
iFocusControlsIter.SetToFirst();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -