Hi! Please consider following me on twitter: @hanekomu.
2002年07月23日
Full-screen movies with QuickTime
The QuickTime Player Applescript Dictionary reveals that the player can indeed play movies at full-screen, so you don't have to get QuickTime Pro for just that. Here's a program that lets you do it from the command-line.
#!/usr/bin/perl use warnings; use strict; use File::Spec; my $movie = shift || die "usage: $0 movie\n"; my $path = File::Spec->rel2abs($movie); my $script = EOAS; set thefile to get POSIX file "$path" tell application "QuickTime Player" activate open thefile present movie 1 scale screen end tell EOAS exec '/usr/bin/osascript', '-e', $script; die "can't exec osascript: $?";
posted at: 16:53 | path: /dev | permalink | 0 comments | 0 trackbacks
Spoken news
Hear your favourite RSS newsfeeds: Take some LWP, a little XML::RSS and season with command-line driven AppleScript.
#!/usr/bin/perl use warnings; use strict; use XML::RSS; use LWP::Simple; $|++; my %news = ( slashdot => "http://slashdot.org/slashdot.rdf", useperl => "http://use.perl.org/useperl.rss", ); my $key = shift || die "usage: $0 key\n"; die "unknown key\n" unless exists $news{$key}; my $rss = XML::RSS->new or die "can't create XML::RSS?"; eval { $rss->parse(get( $news{$key} )) } and not $@ or die "cannot get or parse content: $@"; for my $item (@{$rss->{items}}) { my $title = $item->{title}; my $spoken = prepare_spoken($title);; print "title: \n"; print "spoken: \n\n"; system('/usr/bin/osascript', '-e', sprintf q!say "%s"!, $spoken) == 0 or die "can't speak '$spoken': $?"; sleep(1); } sub prepare_spoken { local $_ = shift; $_ = lc; s/\.NET/ dot net /gi; s/U\.S\./ U S /gi; s/mozilla/ mo zilla /gi; s/AMD's/ AMDs /gi; s/yapc/ yapsee /gi; s/bsd/ BSD /gi; s/(\d+)-/ $1 /gi; s/(?=\S)\.(?=\S)/ dot /gi; s/(?=\.)/ /g; y/"()//d; $_ }
Note that prepare_spoken is rather primitive; some more general rules would be appreciated. Send suggestions to marcel@cpan.org.
posted at: 16:29 | path: /dev | permalink | 0 comments | 0 trackbacks