~ci-train-bot/media-hub/media-hub-ubuntu-yakkety-1823

« back to all changes in this revision

Viewing changes to include/com/ubuntu/music/player.h

  • Committer: Thomas Voß
  • Date: 2013-08-13 14:07:37 UTC
  • Revision ID: thomas.voss@canonical.com-20130813140737-ke081xhuotug54hd
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 */
 
18
#ifndef COM_UBUNTU_MUSIC_PLAYER_H_
 
19
#define COM_UBUNTU_MUSIC_PLAYER_H_
 
20
 
 
21
#include "com/ubuntu/music/connection.h"
 
22
#include "com/ubuntu/music/track_list.h"
 
23
 
 
24
#include <chrono>
 
25
#include <memory>
 
26
 
 
27
namespace com
 
28
{
 
29
namespace ubuntu
 
30
{
 
31
namespace music
 
32
{
 
33
class Service;
 
34
 
 
35
class Player
 
36
{
 
37
  public:
 
38
    typedef double PlaybackRate;
 
39
    typedef double Volume;
 
40
    
 
41
    enum PlaybackStatus
 
42
    {
 
43
        playing,
 
44
        paused,
 
45
        stopped
 
46
    };
 
47
 
 
48
    enum LoopStatus
 
49
    {
 
50
        none,
 
51
        track,
 
52
        playlist
 
53
    };
 
54
 
 
55
    Player(const Player&) = delete;
 
56
    ~Player();
 
57
 
 
58
    Player& operator=(const Player&) = delete;
 
59
    bool operator==(const Player&) const = delete;
 
60
 
 
61
    bool can_go_next();
 
62
    void next();
 
63
    
 
64
    bool can_go_previous();
 
65
    void previous();
 
66
    
 
67
    bool can_play();
 
68
    void play();
 
69
    
 
70
    bool can_pause();
 
71
    void pause();
 
72
    
 
73
    bool can_seek();
 
74
    void seek_to(const std::chrono::microseconds& offset);
 
75
    
 
76
    PlaybackStatus playback_status() const;
 
77
    Connection on_playback_status_changed(const std::function<void(PlaybackStatus)>& handler);
 
78
    
 
79
    LoopStatus loop_status() const;
 
80
    void set_loop_status(LoopStatus new_status);
 
81
    Connection on_loop_status_changed(const std::function<void(LoopStatus)>& handler);
 
82
 
 
83
    PlaybackRate playback_rate() const;
 
84
    void set_playback_rate(PlaybackRate rate);
 
85
    Connection on_playback_rate_changed(const std::function<void(PlaybackRate)>& handler);
 
86
 
 
87
    bool is_shuffle() const;
 
88
    void set_shuffle(bool b);
 
89
    Connection on_shuffle_changed(const std::function<void(bool)>& handler);
 
90
 
 
91
    Track::MetaData meta_data_for_current_track() const;
 
92
    Connection on_meta_data_for_current_track_changed(const std::function<void(const Track::MetaData&)>& handler);
 
93
 
 
94
    Volume volume() const;
 
95
    void set_volume(Volume new_volume);
 
96
    Connection on_volume_changed(const std::function<void(Volume)>& handler);
 
97
 
 
98
    PlaybackRate minimum_playback_rate() const;
 
99
    PlaybackRate maximum_playback_rate() const;
 
100
    
 
101
  private:
 
102
    friend class Service;
 
103
 
 
104
    Player(const std::shared_ptr<Service>& parent);
 
105
 
 
106
    struct Private;
 
107
    std::unique_ptr<Private> d;
 
108
};
 
109
}
 
110
}
 
111
}
 
112
 
 
113
#endif // COM_UBUNTU_MUSIC_PLAYER_H_