Changeset 1400

Show
Ignore:
Timestamp:
08/19/06 17:25:23
Author:
miyagawa
Message:

Notify::Audio: Added a dirty hack to get seconds. Will make it a separate plugin later.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Filter/FetchEnclosure.pm

    r841 r1400  
    33use base qw( Plagger::Plugin ); 
    44 
     5use Cwd; 
    56use File::Spec; 
    67use File::Path; 
     
    1920 
    2021    defined $self->conf->{dir} or Plagger->context->error("config 'dir' is not set."); 
     22    # XXX make it Plagger::Util function 
     23    if ($self->conf->{dir} =~ /^[a-zA-Z]/ && $self->conf->{dir} !~ /:/) { 
     24        $self->conf->{dir} = File::Spec->catfile( Cwd::cwd, $self->conf->{dir} ); 
     25    } 
     26     
    2127    unless (-e $self->conf->{dir} && -d _) { 
    2228        Plagger->context->log(warn => $self->conf->{dir} . " does not exist. Creating"); 
     
    3642        } 
    3743 
    38         my $path = File::Spec->catfile($feed_dir, $enclosure->filename); 
     44        my $filename = $enclosure->filename; 
     45        Encode::_utf8_off($filename); 
     46        my $path = File::Spec->catfile($feed_dir, $filename); 
    3947        $context->log(info => "fetch " . $enclosure->url . " to " . $path); 
    4048 
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio.pm

    r1399 r1400  
    22use strict; 
    33use base qw( Plagger::Plugin ); 
     4 
     5use MP3::Info; 
    46 
    57sub init { 
     
    4547    } 
    4648 
    47     for my $enclosures (@{$self->{enclosures}}) { 
    48         $self->log(info => "Play " . $enclosure->local_path); 
    49         $self->play($enclosure->local_path); 
     49    for my $enclosure (@{$self->{enclosures}}) { 
     50        # XXX this should be a separate plugin to handle MP4/WAV/ogg as well! 
     51        my $info   = eval { MP3::Info->new($enclosure->local_path) }; 
     52        my $length = $info ? $info->secs : undef; 
     53        $self->log(info => "Play " . $enclosure->local_path . ($length ? " for $length seconds" : "")); 
     54        $self->play($enclosure->local_path, $length); 
    5055    } 
    5156} 
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio/MSWin32.pm

    r1397 r1400  
    66 
    77sub play { 
    8     my($self, $filename) = @_; 
     8    my($self, $filename, $length) = @_; 
    99    $filename ||= "SystemExclamation"; 
     10    $length   ||= 3; 
    1011 
    11     Win32::Sound::Play($filename); 
     12    Win32::Sound::Play($filename, SND_ASYNC); 
     13    sleep $length; 
    1214} 
    1315 
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio/iTunesWin32.pm

    r1399 r1400  
    66 
    77sub play { 
    8     my($self, $filename) = @_; 
     8    my($self, $filename, $length) = @_; 
    99    $filename or return $self->log(error => "filename is not set"); 
    1010 
    1111    my $itunes = Win32::OLE->new("iTunes.Application"); 
    1212    $itunes->PlayFile($filename); 
     13    sleep $length; 
    1314} 
    1415