POE-Component-NomadJukebox
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'POE::Component::NomadJukebox',
'VERSION_FROM' => 'NomadJukebox.pm', # finds $VERSION
'PREREQ_PM' => {
'Test::More' => 0.32,
'POE' => 0.22,
'MP3::Tag' => undef,
},
);
NomadJukebox.pm view on Meta::CPAN
###
### Copyright (c) 2004 David Davis. All Rights Reserved.
### This module is free software; you can redistribute it and/or
### modify it under the same terms as Perl itself.
###########################################################################
use strict;
use POE;
# import these, the other functions are OO
use POE::Component::NomadJukebox::Device qw(Discover Open ProgressFunc);
use MP3::Tag;
use Carp qw(croak);
our $VERSION = '0.02';
# our device constants
#sub NJB_DEVICE_NJB1 { 0x00 }
#sub NJB_DEVICE_NJB2 { 0x01 }
#sub NJB_DEVICE_NJB3 { 0x02 }
#sub NJB_DEVICE_NJBZEN { 0x03 }
#sub NJB_DEVICE_NJBZEN2 { 0x04 }
NomadJukebox.pm view on Meta::CPAN
my $owner = $heap->{njb}->GetOwner();
$kernel->post($heap->{reply} => 'njb_owner' => $owner);
return $owner;
}
=pod
=head2 send_track => '/path/to/file.mp3' or send_track => <hashref track info>
This will send a file to the Nomad Jukebox. You can specify the full path to
the file, and allow the component to extract the mp3 tags (using MP3::Tag), or
you can specify them yourself with a hashref with the following keys:
FILE => '/path/to/file.mp3',
CODEC => 'MP3', # MP3, WMA, or WAV
TITLE => 'Title of song',
TRACK => '6',
ARTIST => 'Art Ist',
ALBUM => 'POEtry',
GENRE => 'Rock'
NomadJukebox.pm view on Meta::CPAN
FILE => $track,
};
unless (-e $track) {
$kernel->post($heap->{reply} => njb_send_track => $t => undef
=> 'file not found');
return undef;
}
if ($track =~ m/mp3$/i) {
$t->{CODEC} = 'MP3';
# TODO does the jukebox support anything other than MP3
my $mp3 = MP3::Tag->new($track);
if ($mp3) {
($t->{TITLE}, $t->{TRACK}, $t->{ARTIST}, $t->{ALBUM})
= $mp3->autoinfo();
if (exists $mp3->{ID3v1}) {
$t->{GENRE} = $mp3->{ID3v1}->{genre};
}
}
} elsif ($track =~ m/wma$/i) {
# TODO WMA info?
$t->{CODEC} = 'WMA';
NomadJukebox.pm view on Meta::CPAN
During file transfers, the poe engine may slow down a bit. I will
probably fix this by changing transfers to fork beforehand.
=head1 TODO
There are some more api functions I need to cover.
=head1 SEE ALSO
perl(1), L<MP3::Tag>
=cut
set_owner => 'owner name'
Allows you to set the owner's name. Fires njb_set_owner with the owner
info sent in ARG0 and the return value in ARG1.
get_owner
Fires njb_owner event back to parent with owner info in ARG0.
send_track => '/path/to/file.mp3' or send_track => <hashref track info>
This will send a file to the Nomad Jukebox. You can specify the full
path to the file, and allow the component to extract the mp3 tags (using
MP3::Tag), or you can specify them yourself with a hashref with the
following keys:
FILE => '/path/to/file.mp3',
CODEC => 'MP3', # MP3, WMA, or WAV
TITLE => 'Title of song',
TRACK => '6',
ARTIST => 'Art Ist',
ALBUM => 'POEtry',
GENRE => 'Rock'
BUGS
Probably. Send the author an email about the error.
During file transfers, the poe engine may slow down a bit. I will
probably fix this by changing transfers to fork beforehand.
TODO
There are some more api functions I need to cover.
SEE ALSO
perl(1), MP3::Tag
( run in 0.939 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )