Changeset 1397

Show
Ignore:
Timestamp:
08/19/06 16:55:54
Author:
miyagawa
Message:
  • Notify::Audio now just works. MacOSX portes wanted!
  • Added Notify::Audio::iTunesWin32
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio.pm

    r1395 r1397  
    11package Plagger::Plugin::Notify::Audio; 
    22use strict; 
    3 use base qw( Plagger::Plugin::Notify::Eject ); 
     3use base qw( Plagger::Plugin ); 
    44 
    55sub init { 
     
    1111    eval "require $class;"; 
    1212    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: $@"); 
    1414    } 
    1515    bless $self, $class; 
    1616} 
    1717 
    18 sub eject { 
    19     my($self, $context, $args) = @_; 
    20     $self->play($context, $self->conf->{filename}); 
     18sub register { 
     19    my($self, $context) = @_; 
     20    $context->register_hook( 
     21        $self, 
     22        'publish.feed' => \&update, 
     23        'publish.finalize' => \&finalize, 
     24    ); 
     25    $self->{count} = 0; 
    2126} 
    2227 
     28sub update { 
     29    my($self, $context, $args) = @_; 
     30    $self->{count}++ if $args->{feed}->count; 
     31} 
     32 
     33sub finalize { 
     34    my($self, $context, $args) = @_; 
     35    $self->play($self->conf->{filename}) if $self->{count}; 
     36} 
     37 
     38 
    2339sub play { 
    24     my($self, $context, $args) = @_; 
     40    my($self, $filename) = @_; 
    2541    $self->log(warn => "Subclass should override this"); 
    2642} 
     
    5167Audio filename to play. Required. 
    5268 
     69=back 
     70 
     71=head1 TODO 
     72 
     73=over 4 
     74 
     75=item * 
     76 
     77Configurable audio name per feed. 
     78 
     79=item * 
     80 
     81Play enclosures? 
     82 
     83=back 
     84 
    5385=head1 AUTHOR 
    5486 
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio/MSWin32.pm

    r1395 r1397  
    11package Plagger::Plugin::Notify::Audio::MSWin32; 
    22use strict; 
     3use base qw( Plagger::Plugin::Notify::Audio); 
     4 
    35use Win32::Sound; 
    46 
    57sub play { 
    6     my($self, $context, $filename) = @_; 
     8    my($self, $filename) = @_; 
    79    $filename ||= "SystemExclamation"; 
    810 
    9     Win32::Sound::Play($filename, SND_ASYNC); 
     11    Win32::Sound::Play($filename); 
    1012} 
    1113