« lib/Video/PlaybackMachine/EventWheel/FullScreen.pm
↑ Summary
lib/Video/PlaybackMachine/FillProducer/StaticText.pm »
| 1 | package Video::PlaybackMachine::FillProducer::NextSchedule; | ||
| 2 | |||
| 3 | our $VERSION = '0.09'; # VERSION | ||
| 4 | |||
| 5 | #### | ||
| 6 | #### Video::PlaybackMachine::FillProducer::NextSchedule | ||
| 7 | #### | ||
| 8 | #### $Revision$ | ||
| 9 | #### | ||
| 10 | |||
| 11 | use Moo; | ||
| 12 | |||
| 13 | use Carp; | ||
| 14 | |||
| 15 | extends 'Video::PlaybackMachine::FillProducer::TextFrame'; | ||
| 16 | |||
| 17 | use Video::PlaybackMachine::FillProducer::TextFrame::TextTable; | ||
| 18 | use POE; | ||
| 19 | |||
| 20 | use POSIX qw(strftime); | ||
| 21 | |||
| 22 | ############################# Class Constants ############################# | ||
| 23 | |||
| 24 | our $Max_Entries = 5; | ||
| 25 | |||
| 26 | our $Border = 20; | ||
| 27 | |||
| 28 | ############################## Class Methods ############################## | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | ############################# Object Methods ############################## | ||
| 33 | |||
| 34 | ## | ||
| 35 | ## add_text() | ||
| 36 | ## | ||
| 37 | sub add_text { | ||
| 38 | my $self = shift; | ||
| 39 | my ($image) = @_; | ||
| 40 | |||
| 41 | my @entries = $poe_kernel->call('Scheduler', 'query_next_scheduled', $Max_Entries) | ||
| 42 | or return; | ||
| 43 | my $table = | ||
| 44 | Video::PlaybackMachine::FillProducer::TextFrame::TextTable->new( | ||
| 45 | image => $image, | ||
| 46 | border => $Border, | ||
| 47 | ); | ||
| 48 | foreach my $entry (@entries) { | ||
| 49 | my $next_time = strftime '%l:%M', localtime ($entry->start_time()); | ||
| 50 | $table->add_row($next_time, $entry->movie_info()->title()) | ||
| 51 | or last; | ||
| 52 | } | ||
| 53 | |||
| 54 | $table->draw(); | ||
| 55 | |||
| 56 | } | ||
| 57 | |||
| 58 | ## | ||
| 59 | ## is_available | ||
| 60 | ## | ||
| 61 | ## We are available if there is more than one something "next". If | ||
| 62 | ## there's only one thing left on the schedule, we assume that "up | ||
| 63 | ## next" will be enough. | ||
| 64 | ## | ||
| 65 | sub is_available { | ||
| 66 | my $self = shift; | ||
| 67 | |||
| 68 | my @entries = $poe_kernel->call('Scheduler', 'query_next_scheduled', $Max_Entries) | ||
| 69 | or return; | ||
| 70 | |||
| 71 | return scalar @entries > 1; | ||
| 72 | |||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | 1; |