Playback module is changed.
[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
21 #include <Eina.h>
22 #include <UsbConnectionListener.h>
23 #include "playback-mgr.h"
24
25
26 class IMusicControllerListener {
27 public:
28         enum SUsbStorageStatus {
29                 USB_STORAGE_CONNECTED,
30                 USB_STORAGE_DISCONNECTED
31         };
32
33 public:
34         //! This function is invoked when playback is complete.
35         virtual void OnComplete(void) {}
36         //! This function is invoked when playback occurs any error.
37         virtual void OnError(void) {}
38         //! This function is invoked when usb is connected or not.
39         virtual void OnUsbStatusChanged(SUsbStorageStatus status) {}
40         //! This function is invoked when content is updated..
41         virtual void OnUpdateContent(void) {}
42         //! This function is invoked when new song is played.
43         virtual void OnStartPlayback(void) {}
44         //! This function is invoked when the playback is stopped.
45         virtual void OnStopPlayback(void) {}
46         //! This function is invoked when playback is paused.
47         virtual void OnPausePlayback(void) {}
48         //! This function is invoked when playback is resumed.
49         virtual void OnResumePlayback(void) {}
50         //!
51         virtual void OnPosition(int milsec) {}
52 };
53
54
55 class CMusicController {
56 private:
57         struct SMusicController *m;
58
59 public:
60         CMusicController() : m(0) {}
61         virtual ~CMusicController() {}
62         bool FlagCreate(void) { return !!m; }
63
64         bool Create(void);
65         virtual void Destroy(void);
66         
67         bool Start(void);
68         bool Stop(void);
69         bool Resume(void);
70         bool Pause(void);
71
72         bool AddListener(IMusicControllerListener *listener);
73         bool RemoveListener(IMusicControllerListener *listener);
74
75         bool GetCurrentSongIndex(int *ind);
76         bool GetTotalSongs(int *ts);
77         bool GetSonginfoFromIndex(int index, CSongInfo **const csinfo);
78
79         bool SetPosition(int milsec);
80         bool GetPosition(int *const milseconds);
81
82         bool SetCurrentSong(char *mediaid);
83         bool GetCurrentSong(CSongInfo **const sinfo);
84
85         bool UpdatePlaylist(Eina_List *slist, int addmode);
86         bool EmptyPlaylist(void);
87         
88         bool PlayPreviousSong(void);
89         bool PlayNextSong(void);
90         bool PlayIndexSong(int index);
91
92         bool RemoveSong(CSongInfo *sinfo, int index);
93
94         bool MediaGetList(int EListType, void *info, Eina_List **list);
95         bool MediaInsertPlaylist(const char *name, Eina_List *idlist);
96         bool MediaExistPlaylist(const char *name);
97         bool MediaDeletePlaylist(int id);
98         bool MediaRenamePlaylist(int id, const char *name);
99         bool MediaAddmediaPlaylist(int id, Eina_List *idlist);
100         bool MediaRemovemediaPlaylist(int id, Eina_List *idlist);
101         bool MediaAddsongsPlaylist(int lid, Eina_List *list);
102
103         CSongInfo *MediaSongByUri(char *uri);
104
105         bool SetPlayState(EPlayStatus state);
106         EPlayStatus PlayState(void);
107
108         bool SetShuffleState(EShuffleStatus state);
109         EShuffleStatus ShuffleState(void);
110
111         bool SetRepeatState(ERepeatStatus state);
112         ERepeatStatus RepeatState(void);
113 };
114
115
116 #endif /*__MUSIC_CONTROLLER_H__*/