Remove dependency from CPlaybackView to CPlaybackController.
[profile/tv/apps/native/musicplayer.git] / include / music-controller.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __MUSIC_CONTROLLER_H__
18 #define __MUSIC_CONTROLLER_H__
19
20 #include "playback-mgr.h"
21
22 class IMusicControllerListener {
23 public:
24         enum SUsbStorageStatus {
25                 USB_STORAGE_CONNECTED,
26                 USB_STORAGE_DISCONNECTED
27         };
28
29 public:
30         //! This function is invoked when playback is complete.
31         virtual void OnComplete(void) {}
32         //! This function is invoked when playback occurs any error.
33         virtual void OnError(void) {}
34         //! This function is invoked when usb is connected or not.
35         virtual void OnUsbStatusChanged(SUsbStorageStatus status) {}
36         //! This function is invoked when content is updated..
37         virtual void OnUpdateContent(void) {}
38         //! This function is invoked when new song is played.
39         virtual void OnStartPlayback(void) {}
40         //! This function is invoked when the playback is stopped.
41         virtual void OnStopPlayback(void) {}
42         //! This function is invoked when playback is paused.
43         virtual void OnPausePlayback(void) {}
44         //! This function is invoked when playback is resumed.
45         virtual void OnResumePlayback(void) {}
46         //!
47         virtual void OnPosition(int milsec) {}
48         //!
49         virtual void OnEmptyPlaylist(void) {}
50         //!
51         virtual void OnPlayerModeChanged(EPlayerMode mode) {}
52         //!
53         virtual void OnEditButtonsPressed(EPlayerEditBtns editBtns) {}
54         //!
55         virtual void OnRemoteButtonEvent(Evas_Object *eoBtn, EPlayerBtnsEvent ev) {}
56         //!
57         virtual void OnUpdatePlayerUI(void) {}
58 };
59
60
61 class CMusicController {
62 private:
63         struct SMusicController *m;
64
65 public:
66         CMusicController() : m(0) {}
67         virtual ~CMusicController() {}
68         bool FlagCreate(void) { return !!m; }
69
70         bool Create(void);
71         virtual void Destroy(void);
72         
73         bool Start(void);
74         bool Stop(void);
75         bool Resume(void);
76         bool Pause(void);
77
78         bool AddListener(IMusicControllerListener *listener);
79         bool RemoveListener(IMusicControllerListener *listener);
80
81         bool GetCurrentSongIndex(int *ind);
82         bool GetTotalSongs(int *ts);
83         bool GetSonginfoFromIndex(int index, CSongInfo **const csinfo);
84
85         bool SetPosition(int milsec);
86         bool GetPosition(int *const milseconds);
87
88         bool SetCurrentSong(char *mediaid);
89         bool GetCurrentSong(CSongInfo **const sinfo);
90
91         bool UpdatePlaylist(Eina_List *slist, int addmode);
92         bool EmptyPlaylist(void);
93         
94         bool PlayPreviousSong(void);
95         bool PlayNextSong(void);
96         bool PlayIndexSong(int index);
97
98         bool RemoveSong(CSongInfo *sinfo, int index);
99
100         bool MediaGetList(int EListType, void *info, Eina_List **list);
101         bool MediaInsertPlaylist(const char *name, Eina_List *idlist);
102         bool MediaExistPlaylist(const char *name);
103         bool MediaDeletePlaylist(int id);
104         bool MediaRenamePlaylist(int id, const char *name);
105         bool MediaAddmediaPlaylist(int id, Eina_List *idlist);
106         bool MediaRemovemediaPlaylist(int id, Eina_List *idlist);
107         bool MediaAddsongsPlaylist(int lid, Eina_List *list);
108
109         CSongInfo *MediaSongByUri(char *uri);
110
111         bool SetPlayState(EPlayStatus state);
112         EPlayStatus PlayState(void);
113
114         bool SetShuffleState(EShuffleStatus state);
115         EShuffleStatus ShuffleState(void);
116
117         bool SetRepeatState(ERepeatStatus state);
118         ERepeatStatus RepeatState(void);
119
120         void ChangePlayerMode(EPlayerMode mode);
121         void HandlePlaylistEditButtons(EPlayerEditBtns btnId);
122         void HandleRemoteButtons(Evas_Object *eoBtn, EPlayerBtnsEvent ev);
123         void UpdatePlayerUI(void);
124 };
125
126
127 #endif /*__MUSIC_CONTROLLER_H__*/