⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp3playerapplication.cpp

📁 music player developemntm usic player developemntm usic player developemntmusic player developemnt
💻 CPP
字号:
#include "MP3PlayerApplicationPreComp.hpp"#include <GuiExtensions/MmiAlert.hpp>#include <Common/MmiServices.hpp>#include <AddOns/Services/ServiceBroker.hpp>#include <AddOns/Services/Service.hpp>#include <Asc/StackIndicationMsgTypes.hpp>//#include <Devices/Messages/AudioRadioDeviceNotificationMsg.hpp>//#include <Devices/ChargerMsgTypes.hpp>#include <Apc/Accessory.hpp>//#include <Devices/AudioDeviceManager.hpp>//#include <Devices/AudioPathManager.hpp>#include <Kernel/VersionInfo.hpp>#include "MP3PlayerApplication.hpp"#include <Gui/Panel.hpp>#include <MainApp/Settings/MmiSettingsProvider.hpp>MP3PlayerApplication MP3PlayerApplication::m_app;//To display MP3Player App Version info In Engg Mode AppApoxiUseVersionInfo(MP3Player);/*------------------------------------------------------------MP3PlayerApplication------------------------------------------------------------*/MP3PlayerApplication::MP3PlayerApplication():	Base(L"MP3Player", 2750)/*,	m_set_level_descriptor(L"Set level"),	m_set_band_descriptor(L"Set FM band")*/{} /*------------------------------------------------------------~MP3PlayerApplication------------------------------------------------------------*/MP3PlayerApplication::~MP3PlayerApplication(){}/*	------------------------------------------------------------------------	OnStartup	------------------------------------------------------------------------ */void MP3PlayerApplication::OnStartup(){	Base::OnStartup();	FeaturePool* feat_pool = GetFeaturePool();	m_items[MP3Player].Init(this, FeatureID("MP3Player"));//	m_items[MP3PlayerIdle].Init(this, FeatureID("MP3PlayerIdle"), FALSE, TRUE);//	m_items[MinimizeFeature].Init(this, FeatureID("Minimize"));//	m_items[MuteFeature].Init(this, FeatureID("Mute"), TRUE, TRUE);//	m_items[UnmuteFeature].Init(this, FeatureID("Unmute"), FALSE, TRUE);	m_items[SkPlayFeature].Init(this, FeatureID("SkPlay"));	m_items[SkPauseFeature].Init(this, FeatureID("SkPause"));//	m_items[MonoFeature].Init(this, FeatureID("Mono"), TRUE, TRUE);//	m_items[StereoFeature].Init(this, FeatureID("Stereo"), FALSE, TRUE);//	m_items[ListSavedFeature].Init(this, FeatureID("ListSaved"));//	m_items[EditFreqFeature].Init(this, FeatureID("EditFreq"));//	m_items[CloseFeature].Init(this, FeatureID("Close"));		for (INT idx = 0; idx < MP3PlayerFeatureCnt; idx++) {		feat_pool->AddFeature(&m_items[idx]);	}	RegisterMessage(FlipMsg::ID);}/*------------------------------------------------------------OnOpen------------------------------------------------------------*/void MP3PlayerApplication::OnOpen(){//	m_mp3player_state = RadioFmOff;	Base::OnOpen();	m_mp3player_win.Init();	RegisterMessage(CallEventMsg::ID);//	m_mp3player_settings_prov.Init();	m_mp3player_songs_prov.Init();	m_mp3player_songs_list_win.Init(0/*&m_mp3player_songs_prov*/);	m_mp3player_songs_list_win.SetTitle(Tr(L"MP3 list"));	m_mp3player_songs_list_win.SetContextId(ContextID("Dialog"));//	m_mp3player_edit_win.Init(m_device_radio->GetBandLimits());//	m_mp3player_edit_win.SetTitle(Tr(L"Insert frequency"));//	m_mp3player_edit_win.SetContextId(ContextID("Dialog"));/*	FeaturePool* feat_pool = GetFeaturePool();	DataItem item;	item.SetNumber(m_device_radio->GetSearchStopLevel());	m_set_level_property.Init(this, FeatureID("SetSearchQ"), Property::NotifySet, item);	m_set_level_descriptor.AddValue(RadioAudioDevice::SearchStopLevelLow, L"Low");	m_set_level_descriptor.AddValue(RadioAudioDevice::SearchStopLevelMid, L"Medium");	m_set_level_descriptor.AddValue(RadioAudioDevice::SearchStopLevelHigh, L"High");	m_set_level_property.SetDefaultDescriptor(&m_set_level_descriptor);	feat_pool->AddFeature(&m_set_level_property);*//*	item.SetNumber(m_device_radio->GetBandLimits());	m_set_band_property.Init(this, FeatureID("SetBand"), Property::NotifySet, item);	m_set_band_descriptor.AddValue(RadioAudioDevice::BandLimitsEuropeUs, L"Europe");	m_set_band_descriptor.AddValue(RadioAudioDevice::BandLimitsJapan, L"Japan");	m_set_band_property.SetDefaultDescriptor(&m_set_band_descriptor);	feat_pool->AddFeature(&m_set_band_property);*//*	item.SetBoolean(FALSE);	m_radio_prop.Init(this, FeatureID("MP3PlayerIcon"), Property::NotifySet, item);	if (feat_pool != 0) {		feat_pool->AddFeature(&m_radio_prop);	}*/}/*------------------------------------------------------------OnClose------------------------------------------------------------*//*void MP3PlayerApplication::OnClose(){	UnregisterMessage(AccessoryIndMsg::ID);	StackControl::Unsubscribe(AccHandlerId);	UnregisterMessage(ChargerInfoMsg::ID);	StackControl::Unsubscribe(ChrHandlerId);	UnregisterMessage(CallEventMsg::ID);	UnregisterMessage(AudioRadioDeviceNotificationMsg::ID);	//fix for SMS00050708	Base::OnClose();}*//*------------------------------------------------------------GetInstance------------------------------------------------------------*/MP3PlayerApplication* MP3PlayerApplication::GetInstance(){	return &m_app;}/*------------------------------------------------------------OnMessage------------------------------------------------------------*/BOOLEAN MP3PlayerApplication::OnMessage(const Message &msg){	BOOLEAN dispatched = TRUE; 	//AudioPath HeadsetPath(AudioPath::DownlinkPathMonoHeadset);	switch(msg.Id())	{		//to handle radio audio message		/*case AudioRadioDeviceNotificationMsg::ID:			{				AudioRadioDeviceNotificationMsg *radio_audio_msg = 0;				CastMsg(radio_audio_msg, &msg);				//fix for SMS00052341				INT m_audio_notification_type=radio_audio_msg->GetType();				if((m_audio_notification_type == RadioAudioDevice::NotificationTypeStationFound) || (m_audio_notification_type == RadioAudioDevice::NotificationTypeBandLimitsReached))					m_mp3player_win.HandleRadioAudioNotification();			}			break;*/					//to handle battery low msg		/*case ChargerInfoMsg::ID:			{				const ChargerInfoMsg *charger_info_msg;				CastMsg(charger_info_msg, &msg);				if ((charger_info_msg->GetChargerMsgType() == Charger::LowBattery) && (m_mp3player_state != RadioFmOff))				{					if(m_mp3player_state == RadioFmOnMinimized)					{						m_mp3player_state = RadioFmOff;						m_items[MP3PlayerIdle].SetAvailable(FALSE);						m_mp3player_win.CloseMinimized();					}					else					{						m_mp3player_state = RadioFmOff;						m_mp3player_win.Close();					}				}				break;			}*/		//to handle remove headset		/*case AccessoryIndMsg::ID:			{				AccessoryIndMsg *acc_ind_msg = 0;				CastMsg(acc_ind_msg, &msg);				const Accessory& cur_acc = acc_ind_msg->GetAccessory();				// Check if it is a headset indication				if (cur_acc.GetType() == Accessory::HeadSet)				{					AudioAccessoryDetails* mono_headset = AudioAccessoryStore::GetInstance()->GetAccessoryByCfgType(AudioAccessoryDetails::AudioAccessoryCfgHeadset);					// When FM radio app is running close it					//if(!AudioPathManager::GetInstance()->IsPathActive(HeadsetPath)					if (!mono_headset || !mono_headset->GetConnected())					{						if (m_mp3player_state == RadioFmOnMinimized)						{							m_mp3player_state = RadioFmOff;							m_items[MP3PlayerIdle].SetAvailable(FALSE);							m_mp3player_win.CloseMinimized();						}						else						{							m_mp3player_state = RadioFmOff;							m_mp3player_win.Close();						}					}				}				break;			}*/		case CallEventMsg::ID:			{				CallEventMsg *call_event_msg = 0;				CastMsg(call_event_msg, &msg);				switch (call_event_msg->GetEvent().action)				{					case CallEvent::MtcIsWaiting:						// To stop fm radio when there's an incoming call					//case CallEvent::MocInSetup:						//User try to start a call						/*if(m_mp3player_state == RadioFmOn)						{							m_mp3player_state = RadioFmToRestart;							m_mp3player_win.Close(); 						}						else if(m_mp3player_state == RadioFmOnMinimized)						{							m_mp3player_state = RadioFmToRestart;							m_mp3player_win.CloseMinimized();						}*/						m_mp3player_win.Close();					break;					/*case CallEvent::CallReleased:					case CallEvent::CallDisconnected:						//To restart automatically fm radio when						//interrupted by an incoming call						if((m_mp3player_state == RadioFmToRestart) && 							(MainHandler::GetCallHandlingData()->GetCallCount() == 0))							m_mp3player_win.OpenModeless();					break;*/					//Following call state not treated 				}				break;			}		///  On FlipMsg to reactivate the backlight display on subdiplay when flip is closed		case FlipMsg::ID:			{				FlipMsg* flip_msg;				BOOLEAN flip_status; // Flip status flag				CastMsg(flip_msg, &msg);				flip_status = flip_msg->IsFlipOpen() ? TRUE : FALSE; // Set the Flip Status				if (m_mp3player_win.IsOpen())				{					if (!flip_status)					{						/* 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()));					}					else					{						// Set the backlight always on		  				System::GetDisplay()->SetBacklightMode(Display::BacklightModeOn);					}				}			}    		default:			dispatched = Base::OnMessage(msg);			break;	}	return dispatched;}/*	------------------------------------------------------------------------	OnFeatureTriggered	------------------------------------------------------------------------ */BOOLEAN MP3PlayerApplication::OnFeatureTriggered(const FeatureID& feature_id){	//AudioPath HeadsetPath(AudioPath::DownlinkPathMonoHeadset);	if (feature_id == FeatureID("MP3Player")/* || feature_id == FeatureID("MP3PlayerIdle")*/)	{		//mvaclass_call : MP3 PLAYER DEVICE INITIALISATION		mvInt32 status;		mvaClassInitMv500(MVA_SCENARIO_AUDIO_SDC_STREAM);		mvaClassStorageSelectDevice(MVA_CLASS_STORAGE_SD); /* Ramdisk select */		mvaClassStorageInit(MVA_SDC_BUS_WIDTH4BIT,MVA_SDC_CLK_DIV2, 0);		status = mvaClassStorageOpen();		mvaClassInitMv500(MVA_SCENARIO_AUDIO_SDC_STREAM);		mva2ExtCodecMute(MVA_TRUE);		mvaClass_AudioInit_SA(MVA_DSP_STAND_ALONE_MP3);		mvaClass_AudioDspInit_SA();		mva3I2SByPass(0);						if (status == MVA_OK)		{			//GET MP3 FILE LIST			if (m_mp3player_songs_prov.RowCount() > 0) /* LIST NOT EMPTY */			{				m_mp3player_songs_list_win.SetProvider(&m_mp3player_songs_prov);				m_mp3player_songs_list_win.OpenModal();			}			else			{				MmiAlert alert;				alert.Init(Tr(L"No MP3 files present!"));				alert.OpenModeless();				alert.Close();			}		}		else		{			MmiAlert alert;			alert.Init(Tr(L"Card error!"));			alert.OpenModeless();			alert.Close();		}		return TRUE;				}/*	else if (feature_id == "Minimize")	{		//minimize window means display idle with radio on		SetRadioOn(MP3PlayerApplication::RadioFmOnMinimized);		m_items[MP3PlayerIdle].SetAvailable(TRUE);		m_mp3player_win.Close();		return TRUE;	}*/	else if ((feature_id == "SkPlay")/* || (feature_id == "Mute")*/)	{		//mvaclass_call : RESUME THE PLAYBACK		mvaClass_AudioResume_SA();		//m_items[MuteFeature].SetAvailable(FALSE);		//m_items[UnmuteFeature].SetAvailable(TRUE);		m_mp3player_win.SetContextId(ContextID("MP3Player.MainWinPlay"));		m_mp3player_win.ResumePlaybackTimer();		m_mp3player_win.ResumeSpectrumAnalyserTimer();		GetInstance()->GetPanel()->Invalidate();		return TRUE;	}	else if ((feature_id == "SkPause")/* || (feature_id == "Unmute")*/)	{		//mvaclass_call : PAUSE THE PLAYBACK		mvaClass_AudioPause_SA();		//m_items[UnmuteFeature].SetAvailable(FALSE);		//m_items[MuteFeature].SetAvailable(TRUE);		m_mp3player_win.SetContextId(ContextID("MP3Player.MainWinPause"));		m_mp3player_win.PausePlaybackTimer();		m_mp3player_win.PauseSpectrumAnalyserTimer();		GetInstance()->GetPanel()->Invalidate();		return TRUE;	}/*	else if (feature_id == "Mono")	{		m_device_radio->SetStereoMode(RadioAudioDevice::ModeMono);		m_items[MonoFeature].SetAvailable(FALSE);		m_items[StereoFeature].SetAvailable(TRUE);		m_mp3player_win.UpdateRadioDisplay();		return TRUE;	}	else if (feature_id == "Stereo")	{		m_device_radio->SetStereoMode(RadioAudioDevice::ModeStereo);		m_items[StereoFeature].SetAvailable(FALSE);		m_items[MonoFeature].SetAvailable(TRUE);		m_mp3player_win.UpdateRadioDisplay();		return TRUE;	}	else if (feature_id == "ListSaved")	{		//to display frequencies stored in ffs		m_mp3player_freq_list_win.OpenModal();		return TRUE;	}	else if (feature_id == "EditFreq")	{		//to insert  by keyboard a frequency		m_mp3player_edit_win.OpenModal();		return TRUE;	}	else if (feature_id == "Close")	{		//close fm radio		SetRadioOn(MP3PlayerApplication::RadioFmOff);		m_items[MP3PlayerIdle].SetAvailable(FALSE);		m_mp3player_win.Close();		return TRUE;	}*/	return Base::OnFeatureTriggered(feature_id);}/*	------------------------------------------------------------------------	OnPropertyNotification	------------------------------------------------------------------------ *//*BOOLEAN MP3PlayerApplication::OnPropertyNotification(const Property::Notification notification, 													const Property* property, 													const DataItem& value){	BOOLEAN dispatched = FALSE;	MmiAlert alert;	DataItem item;	if (notification == Property::NotifySet) {		if (property->GetFeatureId() == m_set_level_property.GetFeatureId()) {			if (m_device_radio->SetSearchStopLevel((RadioAudioDevice::SearchStopLevel)value.GetNumber())) {				switch (value.GetNumber()) {					case RadioAudioDevice::SearchStopLevelLow:						alert.Init(Tr(L"Low level has been set"), 2000);						break;					case RadioAudioDevice::SearchStopLevelMid:						alert.Init(Tr(L"Medium level has been set"), 2000);						break;					case RadioAudioDevice::SearchStopLevelHigh:						alert.Init(Tr(L"High level has been set"), 2000);						break;					default:						break;				}			}			else { // problems, restore old value !!!				item.SetNumber(m_device_radio->GetSearchStopLevel());				m_set_level_property.Init(this, FeatureID("SetSearchQ"), Property::NotifySet, item);				alert.Init(Tr(L"New level has not been set"), 2000);			}			alert.OpenModal();			alert.Close();			dispatched = TRUE;		}		else if (property->GetFeatureId() == m_set_band_property.GetFeatureId()) {			if (m_device_radio->SetBandLimits((RadioAudioDevice::BandLimits)value.GetNumber())) {				switch (value.GetNumber()) {					case RadioAudioDevice::BandLimitsEuropeUs:						alert.Init(Tr(L"Fm Radio Europe band has been selected"), 2000);						break;					case RadioAudioDevice::BandLimitsJapan:						alert.Init(Tr(L"Fm Radio Japan Band has been selected"), 2000);						break;					default:						break;				}			}			else { // problems, restore old value !!!				item.SetNumber(m_device_radio->GetBandLimits());				m_set_band_property.Init(this, FeatureID("SetBand"), Property::NotifySet, item);				alert.Init(Tr(L"New band has not been set"), 2000);						}			alert.OpenModal();			alert.Close();			dispatched = TRUE;		}	}	return dispatched || Base::OnPropertyNotification(notification, property, value);	}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -