人気ブログランキング | 話題のタグを見る
Raspbian ウブンツでAIFFもFLACもランダム再生-3
Raspbian ウブンツでAIFFもFLACもランダム再生-3_f0021035_00564153.png
最新情報

splay.pl をターミナルを使わずにワンタッチで起動する pi.pl (改訂版)である。必要なアプリをインストールする。

sudo apt-get install perl-tk

sudo apt-get install gnome-terminal

sudo apt-get install mplayer

sudo apt-get install rtmpdump

sudo apt-get install swftools

sudo apt-get install libxml2-utils

Raspbian ウブンツでAIFFもFLACもランダム再生-3_f0021035_01032161.gifraspA.gif







radio(解凍する)

play_radiko.sh、play_nhk-radio.sh を GitHub から入手する。

2017-10-8 スクリプトミス 一部修正しました




pi.pl は以下




#!/usr/bin/perl

use Tk;
use Encode;

## pi.pl# 改訂版 初期設定 ###################################################

my $msg = "yes"; #シャットダウン時にメセージを表示する yes/no

my $geometry = "+10+40"; #表示位置
my $minsize1 = 460; #サイズW
my $minsize2 = 140; #サイズH
my $tmGeometry = "42x3+10+210"; #gnorm-terminal サイズ/表示位置
my $pVol = "75"; #初期ボリューム
my $font = "MS ゴシック 8 bold"; #フォント

my $bt0Img = "./raspA.gif"; #aplayボタン 画像
my $bt0Bac = "#fffacd"; #aplayボタン 背景色
my $bt0ABac = "#ffff00"; #aplayボタン アクティブ背景色

my $nextTxt = "▶"; #ネクストボタン テキスト(Aplay 専用)
my $nextFont = "MS ゴシック 18 bold"; #フォント
my $nextFore = "#333333"; #ネクストボタン 文字色
my $nextAFore = "#ffffff"; #ネクストボタン アクティブ文字色

my $stopTxt = "×"; #ストップボタン テキスト(gnorm-terminal を閉じる)
my $stopFore = "#333333"; #ストップボタン 文字色
my $stopAFore = "#ffffff"; #ストップボタン アクティブ文字色
my $stopABase = "#113355"; #ストップボタン アクティブ背景色

my $swTxt = "◯"; #シャットダウン テキスト
my $swFont = "MS ゴシック 18 bold"; #シャットダウン フォント
my $swBac = "#555555"; #シャットダウン 背景色
my $swABac = "#b50008"; #シャットダウン アクティブ背景色
my $swFore = "#dddddd"; #シャットダウン 文字色
my $swAFore = "#ffffff"; #シャットダウン アクティブ文字色

my $volFore = "#333333"; #ボリューム 文字色
my $volBac = "#fff0f5"; #ボリューム 背景色
my $volABac = "#da70d6"; #ボリューム アクティブ色

my $bt1Id = "TBS"; #Radico1 ID (http://www.norikistudio.com/station-id-list)
my $bt1Txt = "TBS"; #Radico1 テキスト
my $bt1Fore = "#333333"; #Radico1 文字色
my $bt1Bac = "#40e0d0"; #Radico1 背景色
my $bt1AFore = "#dedede"; #Radico1 アクティブ文字色
my $bt1ABac = "#333333"; #Radico1 アクティブ背景色

my $bt2Id = "FMJ"; #Radico2 ID (http://www.norikistudio.com/station-id-list)
my $bt2Txt = "FMJ"; #Radico2 テキスト
my $bt2Fore = "#333333"; #Radico2 文字色
my $bt2Bac = "#87cefa"; #Radico2 背景色
my $bt2AFore = "#dedede"; #Radico2 アクティブ文字色
my $bt2ABac = "#333333"; #Radico2 アクティブ背景色

my $bt3Id = "r1"; #らじるらじる1 ID=r1:NHKラジオ第1/r2:NHKラジオ第2/fm:NHK FM
my $bt3Txt = "NHK1"; #らじるらじる1 テキスト
my $bt3Fore = "#333333"; #らじるらじる1 文字色
my $bt3Bac = "#ffd700"; #らじるらじる1 背景色
my $bt3AFore = "#dedede"; #らじるらじる1 アクティブ文字色
my $bt3ABac = "#333333"; #らじるらじる1 アクティブ背景色

my $bt4Id = "fm"; #らじるらじる2 ID=r1:NHKラジオ第1/r2:NHKラジオ第2/fm:NHK FM
my $bt4Txt = "N-FM"; #らじるらじる2 テキスト
my $bt4Fore = "#333333"; #らじるらじる2 文字色
my $bt4Bac = "#ffe4e1"; #らじるらじる2 背景色
my $bt4AFore = "#dedede"; #らじるらじる2 アクティブ文字色
my $bt4ABac = "#333333"; #らじるらじる2 アクティブ背景色

#SHOUTcastボタン
#ID アクティブ背景色 文字色 背景色 アクティブ文字色 テキスト
my $s1Id = "1734059"; my $s1Ab = "#333333"; my $s1Fo = "#333333"; my $s1Ba = "#98fb98"; my $s1Af = "#dedede"; my $s1Tx = "WNCS";#WNCS The Point!
my $s2Id = "1331549"; my $s2Ab = "#333333"; my $s2Fo = "#333333"; my $s2Ba = "#da70d6"; my $s2Af = "#dedede"; my $s2Tx = "Jamm";#Jamm FM
my $s3Id = "297368"; my $s3Ab = "#333333"; my $s3Fo = "#333333"; my $s3Ba = "#db7093"; my $s3Af = "#dedede"; my $s3Tx = "smooth";#Smooth Jazz Florida Plus
my $s4Id = "15953"; my $s4Ab = "#333333"; my $s4Fo = "#333333"; my $s4Ba = "#ffa500"; my $s4Af = "#dedede"; my $s4Tx = "EI";#El Tocadiscos

my $s5Id = "1108330"; my $s5Ab = "#333333"; my $s5Fo = "#333333"; my $s5Ba = "#c0c0c0"; my $s5Af = "#dedede"; my $s5Tx = "NST";#Nonstop Casiopea
my $s6Id = "1477271"; my $s6Ab = "#333333"; my $s6Fo = "#333333"; my $s6Ba = "#dda0dd"; my $s6Af = "#dedede"; my $s6Tx = "BEST";#BEST SMOOTH JAZZ - UK (LONDON) HOST ROD LUCAS
my $s7Id = "1323717"; my $s7Ab = "#333333"; my $s7Fo = "#f8f8ff"; my $s7Ba = "#dc143c"; my $s7Af = "#dedede"; my $s7Tx = "LOUNGE";#PulsRadio LOUNGE
my $s8Id = "1292701"; my $s8Ab = "#333333"; my $s8Fo = "#333333"; my $s8Ba = "#f0e68c"; my $s8Af = "#dedede"; my $s8Tx = "Lounge";#Nonstop Casiopea

my $s9Id = "1563396"; my $s9Ab = "#333333"; my $s9Fo = "#333333"; my $s9Ba = "#fff5ee"; my $s9Af = "#dedede"; my $s9Tx = "Gloval";#SmoothJazz.com Global
my $s10Id = "419932"; my $s10Ab = "#333333"; my $s10Fo = "#333333"; my $s10Ba = "#da70d6"; my $s10Af = "#dedede"; my $s10Tx = "WSJE";#WSJE-DB - Smooth Jazz Expressions
my $s11Id = "1077152"; my $s11Ab = "#333333"; my $s11Fo = "#333333"; my $s11Ba = "#9acd32"; my $s11Af = "#dedede"; my $s11Tx = "World";#The world
my $s12Id = "1586446"; my $s12Ab = "#333333"; my $s12Fo = "#333333"; my $s12Ba = "#da70d6"; my $s12Af = "#dedede"; my $s12Tx = "Jpop";#J-Pop Sakura 17

my @Id = ($s1Id,$s2Id,$s3Id,$s4Id,$s5Id,$s6Id,$s7Id,$s8Id,$s9Id,$s10Id,$s11Id,$s12Id);
my @Tx = ($s1Tx,$s2Tx,$s3Tx,$s4Tx,$s5Tx,$s6Tx,$s7Tx,$s8Tx,$s9Tx,$s10Tx,$s11Tx,$s12Tx);
my @Ab = ($s1Ab,$s2Ab,$s3Ab,$s4Ab,$s5Ab,$s6Ab,$s7Ab,$s8Ab,$s9Ab,$s10Ab,$s11Ab,$s12Ab);
my @Af = ($s1Af,$s2Af,$s3Af,$s4Af,$s5Af,$s6Af,$s7Af,$s8Af,$s9Af,$s10Af,$s11Af,$s12Af);
my @Ba = ($s1Ba,$s2Ba,$s3Ba,$s4Ba,$s5Ba,$s6Ba,$s7Ba,$s8Ba,$s9Ba,$s10Ba,$s11Ba,$s12Ba);
my @Fo = ($s1Fo,$s2Fo,$s3Fo,$s4Fo,$s5Fo,$s6Fo,$s7Fo,$s8Fo,$s9Fo,$s10Fo,$s11Fo,$s12Fo);

my $padxi = 0;
my $padyi = 0;

#####################################################################

my $bTi = 0;

$mw = new MainWindow();
$mw->minsize($minsize1,$minsize2);
$mw->geometry("$geometry");

$main = $mw->Frame();
$main->pack(
-side => "top",
-fill => "both",
-expand => "yes",
);

$mainL = $main->Frame();
$mainL->pack(
-side => "left",
);

$image = $mainL->Photo( -file => "$bt0Img" );
$bt0 = $mainL->Button(
-image => $image,
-relief => "flat",
-background => "$bt0Bac",
-activebackground => "$bt0ABac",
-padx => 0,
-pady => 0,
-command => \&Ap,
);
$bt0->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$mainL2 = $mainL->Frame();
$mainL2->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$next = $mainL2->Button(
-relief => "flat",
-text => decode("utf8", "$nextTxt"),
-font => "$nextFont",
-activeforeground => "$nextAFore",
-foreground => "$nextFore",
-background => "$bt0Bac",
-activebackground => "$bt0ABac",
-padx => 0,
-pady => 0,
-command => \&Next,
);
$next->pack(
-side => "top",
-fill => "both",
-expand => "yes",
);

$stop = $mainL2->Button(
-relief => "flat",
-text => decode("utf8", "$stopTxt"),
-font => "$font",
-activeforeground => "$stopAFore",
-foreground => "$stopFore",
-background => "$bt0Bac",
-activebackground => "$stopABase",
-padx => 0,
-pady => 0,
-command => \&Chk,
);
$stop->pack(
-side => "top",
-fill => "both",
-expand => "yes",
);

$mainR = $main->Frame();
$mainR->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$mainR1 = $mainR->Frame(
-padx => $padxi,
-pady => $padyi,
);
$mainR1->pack(
-side => "top",
-fill => "both",
-expand => "yes",
);

$bt1 = $mainR1->Button(
-relief => "flat",
-text => decode("utf8", "$bt1Txt"),
-font => "$font",
-activebackground => "$bt1ABac",
-activeforeground => "$bt1AFore",
-background => "$bt1Bac",
-foreground => "$bt1Fore",
-padx => $padxi,
-pady => $padyi,
-command => \&Nr1,
);
$bt1->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$bt2 = $mainR1->Button(
-relief => "flat",
-text => decode("utf8", "$bt2Txt"),
-font => "$font",
-activebackground => "$bt2ABac",
-activeforeground => "$bt2AFore",
-background => "$bt2Bac",
-foreground => "$bt2Fore",
-padx => $padxi,
-pady => $padyi,
-command => \&Nr2,
);
$bt2->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$bt3 = $mainR1->Button(
-relief => "flat",
-text => decode("utf8", "$bt3Txt"),
-font => "$font",
-activebackground => "$bt3ABac",
-activeforeground => "$bt3AFore",
-background => "$bt3Bac",
-foreground => "$bt3Fore",
-padx => $padxi,
-pady => $padyi,
-command => \&Nr3,
);
$bt3->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$bt4 = $mainR1->Button(
-relief => "flat",
-text => decode("utf8", "$bt4Txt"),
-font => "$font",
-activebackground => "$bt4ABac",
-activeforeground => "$bt4AFore",
-background => "$bt4Bac",
-foreground => "$bt4Fore",
-padx => $padxi,
-pady => $padyi,
-command => \&Nr4,
);
$bt4->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);


for($i = 0; $i < 12; $i++){
if($i == 0||$i == 4||$i == 8){
if($i == 0){$fii = 1;}elsif($i == 4){$fii = 2;}elsif($i == 8){$fii = 3;}
$mainRs[$fii] = $mainR->Frame(
-padx => $padxi,
-pady => $padyi,
);
$mainRs[$fii]->pack(
-side => "top",
-fill => "both",
-expand => "yes",
);
}


$sh[$i] = $mainRs[$fii]->Button(
-relief => "flat",
-text => decode("utf8", "$Tx[$i]"),
-font => "$font",
-activebackground => "$Ab[$i]",
-activeforeground => "$Af[$i]",
-background => "$Ba[$i]",
-foreground => "$Fo[$i]",
-padx => $padxi,
-pady => $padyi,
-command => [ \&Scast,$Id[$i] ],
);
$sh[$i]->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);
}

$mvol = $mw->Frame();
$mvol->pack(
-side => "top",
-fill => "both",
-expand => "yes",
);

$sc = $mvol->Scale(
-orient => "horizontal",
-from => 0,
-to => 100,
-variable => \$vol,
-command => \&Cv,
-activebackground => "$volABac",
-background => "$volBac",
-foreground => "$volFore",
);

$sc->set($pVol);

$sc->pack(
-side => "left",
-fill => "both",
-expand => "yes",
);

$sw = $mvol->Button(
-text => decode("utf8", "$swTxt"),
-font => "$swFont",
-relief => "flat",
-text => decode("utf8", "$swTxt"),
-font => "$font",
-activeforeground => "$swAFore",
-activebackground => "$swABac",
-background => "$swBac",
-foreground => "$swFore",
-padx => 0,
-pady => 0,
-command => \&Sdown,
);
$sw->pack(
-side => "left",,
);

MainLoop;

#####################################################################

sub Ap{
&Chk;
$bTi = 8;
system("gnome-terminal --geometry=$tmGeometry -e \"perl splay.pl -def -list\"");
}

sub Chk{
if($bTi){system("killall -s HUP gnome-terminal-server"); $bTi = 0;};
#Terminal Window Close
}

sub Next{
system("killall -s HUP aplay mpg321 vlc");
}

sub Nr1{
&Chk;
$bTi = 8;
system("gnome-terminal --geometry=$tmGeometry -e \"/home/pi/play_radiko.sh $bt1Id\""); #ID
}

sub Nr2{
&Chk;
$bTi = 8;
system("gnome-terminal --geometry=$tmGeometry -e \"/home/pi/play_radiko.sh $bt2Id\""); #ID
}

sub Nr3{
&Chk;
$bTi = 8;
system("gnome-terminal --geometry=$tmGeometry -e \"/home/pi/play_nhk-radio.sh $bt3Id\""); #ID
}

sub Nr4{
&Chk;
$bTi = 8;
system("gnome-terminal --geometry=$tmGeometry -e \"/home/pi/play_nhk-radio.sh $bt4Id\""); #ID
}

sub Scast{
&Chk;
$bTi = 8;
system("gnome-terminal --geometry=$tmGeometry -e \"mplayer -playlist http://yp.shoutcast.com/sbin/tunein-station.pls?id=$_[0]\""); #ID
}

sub Cv{
system("amixer -c 0 sset PCM $vol\%"); #ヴォリューム USB (ライン出力の場合は 1 を 0 に)
}

sub Sdown{
if($msg eq "yes"){
my $msgbox = $mw->messageBox(
-title => "really",
-icon => "question",
-type => "OkCancel",
-default => "Cancel",
-message => decode("utf8", "シャットダウン!?"),
);
if($msgbox eq 'Ok'){system("sudo shutdown -h now");}else{return;
}
}
else{system("sudo shutdown -h now");} #Stop
}

###########/home/pi/pi.pl 改訂版 ##################ここまで


すべて同じフォルダに置く

$ sudo chmod 755 play_radiko.sh
$ sudo chmod 755 play_nhk-radio.sh
$ sudo chmod 777 radio
$ sudo chmod 755 pi.pl

ラズベリーパイを起動して、ログインした画面にデーモン小暮として Perl/TK による操作画面を表示するには、

/home/pi/.profile

の下の方に Perl/TK のスクリプトファイル( pi.pl )を起動するように記述する。

sudo -u pi perl /home/pi/pi.pl &

ターミナルで

perl pi.pl

でもよい


by digressive | 2017-09-11 01:21 | プアオーディオ | Comments(2)
Commented by かえる at 2017-11-23 11:06 x
シェルスクリプトですねぇ。
ログインしたとき、放送局が立ち上がり、ログアウトするまで切れないという感じでしょうか?
Commented by digressive at 2017-11-23 18:19
ラジオ放送を随時データ化して随時ネット配信しているので、ラジオと時間がずれるんですね。
<< Raspbian で i2s DAC Raspbian ウブンツでA... >>




フリーページあります。

non6 museum

non6 tools

non6 memo



人間は、考える足である。
by ラーメン
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
カテゴリ
全体
熟年マカー失業録
DTPに花束を
すみません、取り乱しました。
マカーはケチだから
Ubuntu
プアオーディオ
ペンタブしよう
non6 nuseum
リンク
_f0021035_17382547.gif



ホームページ作成
WEBデザイン(Perl PHP MySQL)
グラフィックデザイン
CI 各種印刷物 広告 SP
はじめました。



NON6 MUSEUM ANEX


■□■□■□




RandomReading《読書記録》
通勤電車が私の書斎さ。
■□■□■□





WEBカラーネーム

WEBカラーチャート

植草一秀の『知られざる真実』
頑張れミラーマン

世に倦む日々
無料版です

天木直人.com
多少偏向していそうだが、
文春よりは参考になる


きっこのブログ
謎のブログ、リンクしていいのかな?

とりまきメモ
ブログというより、日記帳ですね。

LINK MEMO
小生の勝手なリンク集

pixiv

お気に入りブログ
世に倦む日日
絵と音楽のコラボレーショ...
ライフログ
検索
タグ
ブログパーツ
  • 仕様の関係で、右クリックできません。