~ricmm/+junk/unity-lens_music-sc

« back to all changes in this revision

Viewing changes to src/player-service.vala

  • Committer: Ricardo Mendoza
  • Date: 2012-09-05 14:20:15 UTC
  • Revision ID: ricardo.mendoza@canonical.com-20120905142015-prem6hiyfshwgm8q
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * 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 General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by Pawel Stolowski <pawel.stolowski@canonical.com>
 
17
 */
 
18
 
 
19
namespace PreviewPlayer
 
20
{
 
21
  [DBus (name = "com.canonical.Unity.Lens.Music.PreviewPlayer")]
 
22
  public class PreviewPlayerService : Object
 
23
  {
 
24
    private PreviewPlayer player;
 
25
    private bool released;
 
26
    
 
27
    public PreviewPlayerService (PreviewPlayer preview_player)
 
28
    {
 
29
      released = false;
 
30
      player = preview_player;
 
31
      player.progress.connect (on_progress_change);
 
32
    }
 
33
    
 
34
    private void on_progress_change (string uri, uint32 state, double value)
 
35
    {
 
36
      progress (uri, state, value);
 
37
    }
 
38
    
 
39
    public void play (string uri)
 
40
    {
 
41
      if (released)
 
42
      {
 
43
        released = false;
 
44
        var app = GLib.Application.get_default ();
 
45
        app.hold ();
 
46
      }
 
47
      player.play (uri);
 
48
    }
 
49
    
 
50
    public void pause ()
 
51
    {
 
52
      player.pause ();
 
53
    }
 
54
 
 
55
    public void resume ()
 
56
    {
 
57
      player.resume ();
 
58
    }
 
59
 
 
60
    public void pause_resume ()
 
61
    {
 
62
      player.pause_resume ();
 
63
    }
 
64
    
 
65
    public void stop ()
 
66
    {
 
67
      player.stop ();
 
68
    }
 
69
 
 
70
    public void close ()
 
71
    {
 
72
      if (released)
 
73
        return;
 
74
      released = true;
 
75
      player.stop ();
 
76
      var app = GLib.Application.get_default ();
 
77
      app.release ();
 
78
 
 
79
    }
 
80
 
 
81
    public HashTable<string, Variant> video_properties (string uri)
 
82
    {
 
83
      if (released)
 
84
      {
 
85
        released = false;
 
86
        var app = GLib.Application.get_default ();
 
87
        app.hold ();
 
88
      }
 
89
      return player.get_video_file_props (uri);
 
90
    }
 
91
 
 
92
    public signal void progress (string uri, uint32 state, double value);
 
93
  }
 
94
}
 
 
b'\\ No newline at end of file'