Changeset 1397
- Timestamp:
- 08/19/06 16:55:54
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Notify/Audio.pm
r1395 r1397 1 1 package Plagger::Plugin::Notify::Audio; 2 2 use strict; 3 use base qw( Plagger::Plugin ::Notify::Eject);3 use base qw( Plagger::Plugin ); 4 4 5 5 sub init { … … 11 11 eval "require $class;"; 12 12 if ($@) { 13 Plagger->context->error("Notify plugin doesn't run on your platform $player ");13 Plagger->context->error("Notify plugin doesn't run on your platform $player: $@"); 14 14 } 15 15 bless $self, $class; 16 16 } 17 17 18 sub eject { 19 my($self, $context, $args) = @_; 20 $self->play($context, $self->conf->{filename}); 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; 21 26 } 22 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 23 39 sub play { 24 my($self, $ context, $args) = @_;40 my($self, $filename) = @_; 25 41 $self->log(warn => "Subclass should override this"); 26 42 } … … 51 67 Audio filename to play. Required. 52 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 53 85 =head1 AUTHOR 54 86 trunk/plagger/lib/Plagger/Plugin/Notify/Audio/MSWin32.pm
r1395 r1397 1 1 package Plagger::Plugin::Notify::Audio::MSWin32; 2 2 use strict; 3 use base qw( Plagger::Plugin::Notify::Audio); 4 3 5 use Win32::Sound; 4 6 5 7 sub play { 6 my($self, $ context, $filename) = @_;8 my($self, $filename) = @_; 7 9 $filename ||= "SystemExclamation"; 8 10 9 Win32::Sound::Play($filename , SND_ASYNC);11 Win32::Sound::Play($filename); 10 12 } 11 13
