root/trunk/plagger/lib/Plagger/Plugin/Notify/Audio.pm

Revision 1397 (checked in by miyagawa, 14 years ago)
  • Notify::Audio now just works. MacOSX portes wanted!
  • Added Notify::Audio::iTunesWin32
Line 
1 package Plagger::Plugin::Notify::Audio;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 sub init {
6     my $self = shift;
7     $self->SUPER::init(@_);
8
9     my $player = $self->conf->{player} || $^O;
10     my $class  = 'Plagger::Plugin::Notify::Audio::' . $player;
11     eval "require $class;";
12     if ($@) {
13         Plagger->context->error("Notify plugin doesn't run on your platform $player: $@");
14     }
15     bless $self, $class;
16 }
17
18 sub register {
19     my($self, $context) = @_;
20     $context->register_hook(
21         $self,
22         'publish.feed' => \&update,
23         'publish.finalize' => \&finalize,
24     );
25     $self->{count} = 0;
26 }
27
28 sub update {
29     my($self, $context, $args) = @_;
30     $self->{count}++ if $args->{feed}->count;
31 }
32
33 sub finalize {
34     my($self, $context, $args) = @_;
35     $self->play($self->conf->{filename}) if $self->{count};
36 }
37
38
39 sub play {
40     my($self, $filename) = @_;
41     $self->log(warn => "Subclass should override this");
42 }
43
44 1;
45 __END__
46
47 =head1 NAME
48
49 Plagger::Plugin::Notify::Audio - Notifies feed updates via audio file
50
51 =head1 SYNOPSIS
52
53   - module: Notify::Audio
54     config:
55       filename: /path/to/foo.wav
56
57 =head1 DESCRIPTION
58
59 This plugin plays audio file when you've got feed updates.
60
61 =head1 CONFIG
62
63 =over 4
64
65 =item filename
66
67 Audio filename to play. Required.
68
69 =back
70
71 =head1 TODO
72
73 =over 4
74
75 =item *
76
77 Configurable audio name per feed.
78
79 =item *
80
81 Play enclosures?
82
83 =back
84
85 =head1 AUTHOR
86
87 Tatsuhiko Miyagawa
88
89 =head1 SEE ALSO
90
91 L<Plagger>
92
93 =cut
Note: See TracBrowser for help on using the browser.