src/views/PlaybackController.cpp
src/views/SliderWidget.cpp
src/views/Timer.cpp
+ src/views/AlbumCover.cpp
+ src/views/SongTitleLabel.cpp
src/views/ErrorPopupWindow.cpp
src/playback/playlist-mgr.cpp
src/playback/music-controller.cpp
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
+ */
#ifndef __PLAYBACK_VIEW_H__
#define __PLAYBACK_VIEW_H__
public IMusicControllerListener,
public CTimer {
private:
- struct SPlaybackView* m;
+ struct SPlaybackView *m;
private:
static Eina_Bool sm_CbLongpressTimer(void *dt);
void m_DisableCheckAll(Eina_List *list);
void m_SelectItem(SItemInfo *it_info);
void m_UnselectItem(SItemInfo *it_info);
- void m_UpdateCurrentSongThumbnail(void);
- void m_UpdateCurrentSongLabels(void);
void m_UpdateEmptySongInfo(void);
void m_UpdateCtxtView(int playStatus);
void m_UpdateCurrentSongItem(int index);
void m_FromPlaybackToEditMode(void);
void m_DeleteSelectedItems(void);
- void m_AddAlbumCover(void);
void m_AddCurrentSonginfo(void);
SItemInfo *m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo);
SItemInfo *m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item);
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <AppCommon.h>
+#include "i18n.h"
+#include "define.h"
+#include "common.h"
+#include "song_info.h"
+#include "music-controller.h"
+#include "AlbumCover.h"
+
+
+struct SAlbumCover {
+ Evas_Object *eoBase;
+ Evas_Object *eoAlbumCover;
+ CMusicController controller;
+
+ CSongInfo *pSongInfo;
+};
+
+
+void CAlbumCover::m_AddAlbumCover(void)
+{
+ Evas_Object *eoAlbumCover = NULL;
+
+ eoAlbumCover = elm_image_add(m->eoBase);
+ if (!eoAlbumCover)
+ return;
+
+ evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
+
+ elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
+ eoAlbumCover);
+ evas_object_show(eoAlbumCover);
+ m->eoAlbumCover = eoAlbumCover;
+}
+
+
+void CAlbumCover::m_Update(void)
+{
+ char *path = NULL;
+ char buf[MAX_LENGTH];
+
+ ASSERT(m->pSongInfo)
+
+ path = m->pSongInfo->ThumbnailPath();
+ if (path)
+ elm_image_file_set(m->eoAlbumCover, path, NULL);
+ else {
+ snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
+ MUSIC_IMAGE_DEFAULT_THUMB_450);
+ elm_image_file_set(m->eoAlbumCover, buf, NULL);
+ }
+}
+
+
+void CAlbumCover::m_UpdateSongInfo(void)
+{
+ CSongInfo *sinfo = NULL;
+ int index;
+
+ if (!m->controller.GetCurrentSongIndex(&index)) {
+ _ERR(" music get current song index failed ");
+ return;
+ }
+
+ if (!m->controller.GetSonginfoFromIndex(index, &sinfo)) {
+ _ERR(" music get songinfo failed ");
+ return;
+ }
+ m->pSongInfo = sinfo;
+}
+
+
+void CAlbumCover::m_UpdateForEmptySongList(void)
+{
+ char buf[MAX_LENGTH];
+
+ snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
+ MUSIC_IMAGE_DEFAULT_THUMB_450);
+ elm_image_file_set(m->eoAlbumCover, buf, NULL);
+}
+
+
+
+bool CAlbumCover::Create(Evas_Object *eoBase)
+{
+ ASSERT(!m);
+
+ _CREATE_BEGIN{
+ _CHECK(m = new SAlbumCover)
+ _COMMAND{ m->eoBase = eoBase; }
+ _CHECK(m->controller.Create())
+ _CHECK(m->controller.AddListener(this))
+
+ _WHEN_SUCCESS{
+ m_AddAlbumCover();
+ }
+
+ _CHECK_FAIL{ m->controller.RemoveListener(this); }
+ _CHECK_FAIL{ m->controller.Destroy(); }
+ _CHECK_FAIL{ delete m; m = NULL; }
+ } _CREATE_END_AND_CATCH{ return false; }
+
+ return true;
+}
+
+
+void CAlbumCover::Destroy(void)
+{
+ ASSERT(m);
+
+ m->controller.RemoveListener(this);
+ m->controller.Destroy();
+ delete m;
+ m = NULL;
+}
+
+
+void CAlbumCover::OnStartPlayback(void)
+{
+ m_UpdateSongInfo();
+ m_Update();
+}
+
+
+void CAlbumCover::OnEmptyPlaylist(void)
+{
+ m_UpdateForEmptySongList();
+}
+
+
+void CAlbumCover::OnUpdatePlayerUI(void)
+{
+ m_UpdateSongInfo();
+ m_Update();
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ALBUM_COVER_H__
+#define __ALBUM_COVER_H__
+
+class CAlbumCover : public IMusicControllerListener {
+private:
+ struct SAlbumCover *m;
+
+private:
+ void m_AddAlbumCover(void);
+ void m_Update(void);
+ void m_UpdateSongInfo(void);
+ void m_UpdateForEmptySongList(void);
+
+public:
+ CAlbumCover() : m(0) {}
+ virtual ~CAlbumCover() {}
+
+ bool Create(Evas_Object *eoBase);
+ virtual void Destroy(void);
+
+public:
+ //! This function is invoked when new song is played.
+ virtual void OnStartPlayback(void);
+ //! This function is invoked when playlist is empty.
+ virtual void OnEmptyPlaylist(void);
+ //! This function is invoked when player UI need to be updated.
+ virtual void OnUpdatePlayerUI(void);
+};
+
+#endif // __ALBUM_COVER_H__
\ No newline at end of file
}
-void CPlaybackController::m_UpdateForEmptySong(void)
+void CPlaybackController::m_UpdateForEmptySongList(void)
{
elm_object_signal_emit(m->eoBtnControl[CTRL_BTN_PLAY],
MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
void CPlaybackController::OnEmptyPlaylist(void)
{
- m_UpdateForEmptySong();
+ m_UpdateForEmptySongList();
}
void m_DestroyErrorPopup(void);
void m_CreateSettingsPopup(void);
void m_DestroySettingsPopup(void);
- void m_UpdateForEmptySong(void);
+ void m_UpdateForEmptySongList(void);
void m_HandleForwardBtnClicked(Evas_Object *obj);
void m_HandleRewindBtnClicked(Evas_Object *obj);
}
+void CSliderWidget::m_UpdateForEmptySongList(void)
+{
+ elm_object_disabled_set(m->eoSlider, EINA_TRUE);
+ elm_slider_value_set(m->eoSlider, 0);
+ elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
+ elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
+}
+
+
bool CSliderWidget::Create(Evas_Object *eoBase)
{
ASSERT(!m);
}
-void CSliderWidget::Init(void)
-{
- elm_object_disabled_set(m->eoSlider, EINA_TRUE);
- elm_slider_value_set(m->eoSlider, 0);
- elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
- elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
-}
-
-
void CSliderWidget::OnComplete(void)
{
}
}
+void CSliderWidget::OnEmptyPlaylist(void)
+{
+ m_UpdateForEmptySongList();
+}
+
+
void CSliderWidget::OnChanged(int id, Evas_Object *obj)
{
char *timestr = NULL;
void m_RemoveTimer(void);
void m_UpdateSongInfo(void);
+ void m_UpdateForEmptySongList(void);
public:
CSliderWidget() :
Evas_Object* Base(void);
- void Init(void);
-
//! This function is invoked when playback is complete.
virtual void OnComplete(void);
//! This function is invoked when new song is played.
virtual void OnResumePlayback(void);
//! This function is invoked when the position of playback is changed.
virtual void OnPosition(int milsec);
+ //! This function is invoked when playlist is empty.
+ virtual void OnEmptyPlaylist(void);
virtual void OnChanged(int id, Evas_Object *obj);
virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev);
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <AppCommon.h>
+#include "i18n.h"
+#include "define.h"
+#include "common.h"
+#include "song_info.h"
+#include "music-controller.h"
+#include "SongTitleLabel.h"
+
+
+struct SSongTitleLabel {
+ Evas_Object *eoBase;
+ CMusicController controller;
+
+ CSongInfo *pSongInfo;
+
+};
+
+
+void CSongTitleLabel::m_Update(void)
+{
+ char buf[MAX_LENGTH];
+
+ ASSERT(m->pSongInfo);
+
+ elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
+ m->pSongInfo->Name());
+
+ snprintf(buf, sizeof(buf), "%s - %s", m->pSongInfo->Artist(),
+ m->pSongInfo->Album());
+
+ elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
+}
+
+
+void CSongTitleLabel::m_UpdateSongInfo(void)
+{
+ CSongInfo *sinfo = NULL;
+ int index;
+
+ if (!m->controller.GetCurrentSongIndex(&index)) {
+ _ERR(" music get current song index failed ");
+ return;
+ }
+
+ if (!m->controller.GetSonginfoFromIndex(index, &sinfo)) {
+ _ERR(" music get songinfo failed ");
+ return;
+ }
+ m->pSongInfo = sinfo;
+
+}
+
+
+void CSongTitleLabel::m_UpdateForEmptySongList(void)
+{
+ char buf[MAX_LENGTH];
+
+ elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
+ _(NO_PLAYLIST_MESSAGE));
+ elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
+ _(NO_PLAYLIST_MESSAGE_SUB));
+}
+
+
+bool CSongTitleLabel::Create(Evas_Object *eoBase)
+{
+ ASSERT(!m);
+
+ _CREATE_BEGIN{
+ _CHECK(m = new SSongTitleLabel)
+ _COMMAND{ m->eoBase = eoBase; }
+ _CHECK(m->controller.Create())
+ _CHECK(m->controller.AddListener(this))
+
+ _CHECK_FAIL{ m->controller.RemoveListener(this); }
+ _CHECK_FAIL{ m->controller.Destroy(); }
+ _CHECK_FAIL{ delete m; m = NULL; }
+ } _CREATE_END_AND_CATCH{ return false; }
+
+ return true;
+}
+
+
+void CSongTitleLabel::Destroy(void)
+{
+ ASSERT(m);
+
+ m->controller.RemoveListener(this);
+ m->controller.Destroy();
+ delete m;
+ m = NULL;
+}
+
+
+void CSongTitleLabel::OnStartPlayback(void)
+{
+ m_UpdateSongInfo();
+ m_Update();
+}
+
+
+void CSongTitleLabel::OnEmptyPlaylist(void)
+{
+ m_UpdateForEmptySongList();
+}
+
+
+void CSongTitleLabel::OnUpdatePlayerUI(void)
+{
+ m_UpdateSongInfo();
+ m_Update();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SONG_TITLE_LABEL_H__
+#define __SONG_TITLE_LABEL_H__
+
+class CSongTitleLabel : public IMusicControllerListener {
+private:
+ struct SSongTitleLabel *m;
+
+private:
+ void m_Update(void);
+ void m_UpdateSongInfo(void);
+ void m_UpdateForEmptySongList(void);
+
+public:
+ CSongTitleLabel() : m(0) {}
+ virtual ~CSongTitleLabel() {}
+
+ bool Create(Evas_Object *eoBase);
+ virtual void Destroy(void);
+
+public:
+ //! This function is invoked when new song is played.
+ virtual void OnStartPlayback(void);
+ //! This function is invoked when playlist is empty.
+ virtual void OnEmptyPlaylist(void);
+ //! This function is invoked when player UI need to be updated.
+ virtual void OnUpdatePlayerUI(void);
+};
+
+#endif // __SONG_TITLE_LABEL_H__
\ No newline at end of file
#include "Info.h"
#include "SliderWidget.h"
#include "PlaybackController.h"
+#include "AlbumCover.h"
+#include "SongTitleLabel.h"
#define TOTAL_CONTROL_BTNS 6
Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
Evas_Object *eoBtnEdit[TOTAL_EDIT_BTNS];
- Evas_Object *eoAlbumCover;
+ CAlbumCover *pAlbumCover;
CSliderWidget *pSliderWidget;
+ CSongTitleLabel *pSongTitleLabel;
Eina_List *elInfo;
CMusicController *pController; //! NOT NULL
}
-void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
-{
- char *path = NULL;
- char buf[MAX_LENGTH];
-
- if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
- return;
-
- path = m->cs_itinfo->sinfo->ThumbnailPath();
- if (path)
- elm_image_file_set(m->eoAlbumCover, path, NULL);
- else {
- snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
- MUSIC_IMAGE_DEFAULT_THUMB_450);
- elm_image_file_set(m->eoAlbumCover, buf, NULL);
- }
-}
-
-
-void CPlaybackView::m_UpdateCurrentSongLabels(void)
-{
- char buf[MAX_LENGTH];
-
- if (!m->csinfo)
- return;
-
- elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
- m->csinfo->Name());
-
- snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
- m->csinfo->Album());
-
- elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
-}
-
-
void CPlaybackView::m_UpdateEmptySongInfo(void)
{
- char buf[MAX_LENGTH];
-
- m->pSliderWidget->Init();
-
- elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
- _(NO_PLAYLIST_MESSAGE));
- elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
- _(NO_PLAYLIST_MESSAGE_SUB));
- snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
- MUSIC_IMAGE_DEFAULT_THUMB_450);
- elm_image_file_set(m->eoAlbumCover, buf, NULL);
m->pController->SetPlayState(PLAY_STATUS_INITIAL);
}
int index;
if (eina_list_count(m->elInfo) == 0) {
- m_UpdateEmptySongInfo();
+ m->pController->EmptyPlaylist();
return;
}
m->csinfo = sinfo;
m_UpdateCurrentSongItem(index);
- m_UpdateCurrentSongLabels();
- m_UpdateCurrentSongThumbnail();
m->pController->UpdatePlayerUI();
m_UpdatePlaymodeFocusSequence();
}
}
if (eina_list_count(m->elInfo) == 0) {
- m_UpdateEmptySongInfo();
+ m->pController->EmptyPlaylist();
elm_genlist_realized_items_update(m->eoPlaylist);
elm_object_focus_set(m->eoBtnEdit[EDIT_BTN_CANCEL], EINA_TRUE);
return;
}
-void CPlaybackView::m_AddAlbumCover(void)
-{
- Evas_Object *eoAlbumCover = NULL;
-
- eoAlbumCover = elm_image_add(m->eoBase);
- if (!eoAlbumCover)
- return;
-
- evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
-
- elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
- eoAlbumCover);
- evas_object_show(eoAlbumCover);
- m->eoAlbumCover = eoAlbumCover;
-
-}
-
-
void CPlaybackView::m_AddCurrentSonginfo(void)
{
- m_AddAlbumCover();
+ m->pSongTitleLabel = new CSongTitleLabel;
+ m->pSongTitleLabel->Create(m->eoBase);
+
+ m->pAlbumCover = new CAlbumCover;
+ m->pAlbumCover->Create(m->eoBase);
m->pSliderWidget = new CSliderWidget;
m->pSliderWidget->Create(m->eoBase);
m->pSliderWidget->Destroy();
delete m->pSliderWidget;
+ m->pAlbumCover->Destroy();
+ delete m->pAlbumCover;
+
+ m->pSongTitleLabel->Destroy();
+ delete m->pSongTitleLabel;
+
m->pHandleVolume->Destroy();
delete m->pHandleVolume;
CBaseView::Destroy();