📄 mp3playerwindow.cpp
字号:
m_mp3player_image_start.Init(this, &spectrum_analyser_start, -1, -1); m_mp3player_image_bar01.Init(this, NULL, -1, -1); m_mp3player_image_bar02.Init(this, NULL, -1, -1); m_mp3player_image_bar03.Init(this, NULL, -1, -1); m_mp3player_image_bar04.Init(this, NULL, -1, -1); m_mp3player_image_bar05.Init(this, NULL, -1, -1); m_mp3player_image_bar06.Init(this, NULL, -1, -1); m_mp3player_image_bar07.Init(this, NULL, -1, -1); m_mp3player_image_bar08.Init(this, NULL, -1, -1); m_mp3player_image_bar09.Init(this, NULL, -1, -1); m_mp3player_image_bar10.Init(this, NULL, -1, -1); m_mp3player_image_bar11.Init(this, NULL, -1, -1); m_mp3player_image_bar12.Init(this, NULL, -1, -1); m_mp3player_image_bar13.Init(this, NULL, -1, -1); m_mp3player_image_bar14.Init(this, NULL, -1, -1); m_mp3player_image_bar15.Init(this, NULL, -1, -1); m_mp3player_image_end.Init(this, &spectrum_analyser_end, -1, -1); m_playback_timer.Init(1000, TRUE); m_spectrum_analyser_timer.Init(150, TRUE); // Initialise navigation guidance NavigationGuidance nav_guid; nav_guid.SetState(NavigationGuidance::Left, NavigationGuidance::Enabled); nav_guid.SetState(NavigationGuidance::Right, NavigationGuidance::Enabled); nav_guid.SetState(NavigationGuidance::Up, NavigationGuidance::Enabled); nav_guid.SetState(NavigationGuidance::Down, NavigationGuidance::Enabled); SetNavigationGuidance(nav_guid); m_mp3player_app = MP3PlayerApplication::GetInstance();}/*-------------------------------------------------------------OnLayoutClient-------------------------------------------------------------*/void MP3PlayerWindow::OnLayoutClient(){ Base::OnLayoutClient(); //Layouter layouter(1, 7, this); Layouter layouter(1, 5, this); //layouter.StretchYGrid(L"10,20,20,10,20,20,10", Layouter::Percent); layouter.StretchYGrid(L"20,63,20", Layouter::Pixel); Layouter duration_layouter(2, 1, this); duration_layouter.StretchXGrid(L"45,55", Layouter::Percent); Layouter volume_layouter(3, 1, this); volume_layouter.StretchXGrid(L"20,45,63", Layouter::Pixel); Layouter mp3player_image_layouter(17, 1, this); mp3player_image_layouter.StretchXGrid(L"4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4", Layouter::Pixel); layouter.Arrange(0, 0, &duration_layouter); //layouter.Arrange(0, 1, &m_mp3player_image); OLD layouter.Arrange(0, 1, &mp3player_image_layouter); layouter.Arrange(0, 2, &volume_layouter); duration_layouter.Arrange(0, 0, &m_duration_text, Layouter::Center, Layouter::Middle); duration_layouter.Arrange(1, 0, &m_duration_bar, Layouter::Center, Layouter::Middle); volume_layouter.Arrange(0, 0, &m_3d_box, Layouter::Center, Layouter::Middle); volume_layouter.Arrange(1, 0, &m_volume_text, Layouter::Center, Layouter::Middle); volume_layouter.Arrange(2, 0, &m_volume_bar, Layouter::Center, Layouter::Middle); mp3player_image_layouter.Arrange( 0, 0, &m_mp3player_image_start); mp3player_image_layouter.Arrange( 1, 0, &m_mp3player_image_bar01); mp3player_image_layouter.Arrange( 2, 0, &m_mp3player_image_bar02); mp3player_image_layouter.Arrange( 3, 0, &m_mp3player_image_bar03); mp3player_image_layouter.Arrange( 4, 0, &m_mp3player_image_bar04); mp3player_image_layouter.Arrange( 5, 0, &m_mp3player_image_bar05); mp3player_image_layouter.Arrange( 6, 0, &m_mp3player_image_bar06); mp3player_image_layouter.Arrange( 7, 0, &m_mp3player_image_bar07); mp3player_image_layouter.Arrange( 8, 0, &m_mp3player_image_bar08); mp3player_image_layouter.Arrange( 9, 0, &m_mp3player_image_bar09); mp3player_image_layouter.Arrange(10, 0, &m_mp3player_image_bar10); mp3player_image_layouter.Arrange(11, 0, &m_mp3player_image_bar11); mp3player_image_layouter.Arrange(12, 0, &m_mp3player_image_bar12); mp3player_image_layouter.Arrange(13, 0, &m_mp3player_image_bar13); mp3player_image_layouter.Arrange(14, 0, &m_mp3player_image_bar14); mp3player_image_layouter.Arrange(15, 0, &m_mp3player_image_bar15); mp3player_image_layouter.Arrange(16, 0, &m_mp3player_image_end); /*layouter.Arrange(0, 1, &m_duration_bar); layouter.Arrange(0, 2, &m_duration_text); layouter.Arrange(0, 3, &m_mp3player_image); layouter.Arrange(0, 4, &m_volume_bar); layouter.Arrange(0, 5, &m_volume_text);*/}/*-------------------------------------------------------------LoadSavedData-------------------------------------------------------------*//*void MP3PlayerWindow::LoadSavedData(){ DataItem item; UINT8 i; m_fmradio_app->GetMP3PlayerSettingsProv()->Update(); m_fmradio_app->GetMP3PlayerSettingsProv()->SelectRow(0); m_fmradio_app->GetMP3PlayerSettingsProv()->GetDataItem(c_radio_last_volume, 0, item); m_volume = (INT)item.GetNumber(); m_fmradio_app->GetMP3PlayerSettingsProv()->GetDataItem(c_radio_last_freq, 0, item); m_radio_info.m_frequency = item.GetNumber(); for(i = 0; i < c_max_fmradio_stations_records; i++) { m_fmradio_app->GetMP3PlayerSongsProv()->SelectRow(i); m_fmradio_app->GetMP3PlayerSongsProv()->GetDataItem(c_radio_freq, i, item); m_stored_freq[i] = item.GetNumber(); } //check if read from ffs good values if(m_fmradio_app->GetRadioDevice()->GetBandLimits() == RadioAudioDevice::BandLimitsJapan) { if( (m_radio_info.m_frequency < 76000) || (m_radio_info.m_frequency > 91000) ) m_radio_info.m_frequency = 76000; for(i = 0; i < c_max_fmradio_stations_records; i++) { if(m_stored_freq[i] != 0) { if( (m_radio_info.m_frequency < 76000) || (m_radio_info.m_frequency > 91000) ) m_radio_info.m_frequency = 0; } } } else { if( (m_radio_info.m_frequency < 87500) || (m_radio_info.m_frequency > 108000) ) m_radio_info.m_frequency = 87500; for(i = 0; i < c_max_fmradio_stations_records; i++) { if(m_stored_freq[i] != 0) { if( (m_radio_info.m_frequency < 87500) || (m_radio_info.m_frequency > 108000) ) m_radio_info.m_frequency = 0; } } }}*//*-------------------------------------------------------------OnOpen-------------------------------------------------------------*/void MP3PlayerWindow::OnOpen(){ Base::OnOpen(); /*if((m_mp3player_app->GetRadioOn()==MP3PlayerApplication::RadioFmOff)|| (m_mp3player_app->GetRadioOn()==MP3PlayerApplication::RadioFmToRestart))*/ if (1) { if( m_is_mp3player_running ) { m_info.SetText(Tr(L"MP3Player Error")); return; } else { //Load from ffs stored data like frequencies, volume, etc. //LoadSavedData(); if (0) // if there's an error close the player !! { Close(); m_info.SetText(Tr(L"MP3Player Error")); return; } //mvaclass_call : SET THE VOLUME (m_volume) AND START THE CURRENT SONG (m_index_of_song) mvaClass_AudioSetVolume_SA(m_Mmi2DriverVolume[m_volume/VOLUME_STEPS]); m_volume_bar.SetProgress(m_volume); mvaClass_AudioPlay_SA(m_index_of_song); m_is_mp3player_running = TRUE; DataItem item; // Set the backlight always on System::GetDisplay()->SetBacklightMode(Display::BacklightModeOn); // Get title from provider m_mp3player_app->GetMP3PlayerSongsProv()->GetDataItem(c_mp3player_songtitle, m_index_of_song, item); SetTitle(item.GetWString()); // Get length from provider m_mp3player_app->GetMP3PlayerSongsProv()->GetDataItem(c_mp3player_songlength, m_index_of_song, item); m_current_mp3_max_time = (UINT16)(item.GetNumber()); m_current_mp3_max_time_mins = m_current_mp3_max_time / 60; m_current_mp3_max_time_secs = m_current_mp3_max_time - (m_current_mp3_max_time_mins * 60); m_current_mp3_time = 0; m_current_mp3_time_mins = 0; m_current_mp3_time_secs = 0; m_playback_timer.Start(); m_spectrum_analyser_timer.Start(); UpdatePlaybackTimeAndProgressBar(); UpdateSpectrumAnalyser(); } } else { //if(m_mp3player_app->GetRadioOn()==MP3PlayerApplication::RadioFmOnMinimized) if (1) { /*FeatureBroker *broker = FeatureBroker::GetInstance(); if (broker != 0) { Property *prop = (Property*)broker->GetFeature(ApplicationID("MP3Player"), FeatureID("MP3PlayerIcon")); if (prop != 0) { DataItem item; item.SetBoolean(FALSE); prop->SetDataItem(item); } }*/ } if(!m_is_mp3player_running) { m_info.SetText(Tr(L"MP3Player Error")); return; } }}/*-------------------------------------------------------------SwitchOff-------------------------------------------------------------*//*void MP3PlayerWindow::SwitchOff(){ //To really switch off fm radio m_fmradio_app->GetRadioDevice()->Disable(); m_is_fmradio_running = FALSE; //Store info in ffs DataItem item; m_fmradio_app->GetMP3PlayerSettingsProv()->Update(); item.SetNumber(m_volume); m_fmradio_app->GetMP3PlayerSettingsProv()->SetDataItem(item, c_radio_last_volume); item.SetNumber(m_radio_info.m_frequency); m_fmradio_app->GetMP3PlayerSettingsProv()->SetDataItem(item, c_radio_last_freq); m_fmradio_app->GetMP3PlayerSettingsProv()->CommitRow(0); m_fmradio_app->GetMP3PlayerSettingsProv()->Update();}*//*-------------------------------------------------------------CloseMinimized-------------------------------------------------------------*//*void MP3PlayerWindow::CloseMinimized(){ //To switch off fm radio with minimized window SwitchOff(); if((m_fmradio_app->GetRadioOn()==MP3PlayerApplication::RadioFmOff)|| (m_fmradio_app->GetRadioOn()==MP3PlayerApplication::RadioFmToRestart)) { FeatureBroker *broker = FeatureBroker::GetInstance(); if (broker != 0) { Property *prop = (Property*)broker->GetFeature(ApplicationID("MP3Player"), FeatureID("MP3PlayerIcon")); if (prop != 0) { DataItem item; item.SetBoolean(FALSE); prop->SetDataItem(item); } } }}*//*-------------------------------------------------------------OnClose-------------------------------------------------------------*/void MP3PlayerWindow::OnClose(){ /*if((m_fmradio_app->GetRadioOn()==MP3PlayerApplication::RadioFmOff)|| (m_fmradio_app->GetRadioOn()==MP3PlayerApplication::RadioFmToRestart)) { SwitchOff(); } if(m_fmradio_app->GetRadioOn()==MP3PlayerApplication::RadioFmOnMinimized) { FeatureBroker *broker = FeatureBroker::GetInstance(); if (broker != 0) { Property *prop = (Property*)broker->GetFeature(ApplicationID("MP3Player"), FeatureID("MP3PlayerIcon")); if (prop != 0) { DataItem item; item.SetBoolean(TRUE); prop->SetDataItem(item); } } }*/ m_volume_text.SetText(L"Normal"); m_3d_box.SetBitmap(&empty_bit); enable_3d=FALSE; equal_effect=0; m_current_mp3_time = 0; m_current_mp3_time_mins = 0; m_current_mp3_time_secs = 0; m_current_mp3_max_time = 0; m_current_mp3_max_time_mins = 0; m_current_mp3_max_time_secs = 0; //m_spectrum_analyser_index = 0; mvaClass_AudioStop_SA(); mva3I2SByPass(1); /* Get the original setting for backlight from mmisettingsprovider */ Provider *prov = DataControl::GetMainProvider()->GetProvider(c_mmi_settings_provider_id); prov->Update(); DataItem item; prov->SelectRow(0); prov->GetDataItem(c_backlight_id, 0, item); System::GetDisplay()->SetBacklightMode(Display::BacklightMode(item.GetNumber())); m_is_mp3player_running = FALSE; SetContextId(ContextID("MP3Player.MainWinPlay")); Base::OnClose();}/*------------------------------------------------------------OnMessage------------------------------------------------------------*/BOOLEAN MP3PlayerWindow::OnMessage(const Message &msg){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -