summaryrefslogtreecommitdiff
path: root/examples/renderer-plugins/vala/example-player-vala.vala
blob: 04a5a042800e7bef874cfc660d587b9d3ef52dc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 * Copyright (C) 2012 Intel Corporation
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

using GUPnP;

/**
 * Implementation of RygelMediaPlayer.
 *
 * This is an incredibly simple example that does no real rendering,
 * and does not attempt to support audio or video formats. It just prints out
 * the URI that is received from the UPnP control point.
 *
 * RygelPlaybinPlayer, from librygel-renderer-gst, is a more complete example.
 */
public class Rygel.Example.PlayerVala : GLib.Object, Rygel.MediaPlayer {
    private const string[] PROTOCOLS = { "http-get" };
    private const string[] MIME_TYPES = {"image/jpeg",
                                         "image/png" };
    private static PlayerVala player;

    private PlayerVala () {
    }

    public static PlayerVala get_default () {
        if (player == null) {
            player = new PlayerVala ();
        }

        return player;
    }

    private string _playback_state = "NO_MEDIA_PRESENT";
    public string playback_state {
        owned get {
            return this._playback_state;
        }

        set {
            this._playback_state = value;
        }
    }

    private string _uri = "";
    public string? uri {
        owned get {
            return _uri;
        }

        set {
            this._uri = value;

            /*
             * To see this debug output, to see that 
             * the renderer has received the URI,
             * you would need to run rygel like so:
             * $ export G_MESSAGES_DEBUG=all
             * rygel -g 5
             */
            debug ("URI set to %s.", value);
        }
    }

    private string _mime_type = "";
    public string? mime_type {
        owned get {
            return this._mime_type;
        }

        set {
            this._mime_type = value;
        }
    }

    private string _metadata = "";
    public string? metadata {
        owned get {
            return this._metadata;
        }

        set {
            this._metadata = value;
        }
    }

    private string _content_features = "";
    public string? content_features {
        owned get {
            return this._content_features;
        }

        set {
            this._content_features = value;
        }
    }

    private double _volume = 0;
    public double volume {
        get {
            return this._volume;
        }

        set {
            this._volume = value;
            debug ("volume set to %f.", value);
        }
    }

    private int64 _duration = 0;
    public int64 duration {
        get {
            return this._duration;
        }
    }

    private int64 _position = 0;
    public int64 position {
        get {
            return this._position;
        }
    }

    public bool seek (int64 time) {
        return false;
    }

    public string[] get_protocols () {
        return PROTOCOLS;
    }

    public string[] get_mime_types () {
        return MIME_TYPES;
    }
}