… | |
… | |
2045 | |
2045 | |
2046 | # default MUSIC_WANT, undef/0 == MUSIC_DEFAULT |
2046 | # default MUSIC_WANT, undef/0 == MUSIC_DEFAULT |
2047 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
2047 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
2048 | |
2048 | |
2049 | # if the currently playing song is acceptable, let it continue |
2049 | # if the currently playing song is acceptable, let it continue |
|
|
2050 | return if $MUSIC_PLAYING |
2050 | return if grep $MUSIC_PLAYING eq $_->{path}, @MUSIC_WANT; |
2051 | && grep $MUSIC_PLAYING->{path} eq $_->{path}, @MUSIC_WANT; |
2051 | |
2052 | |
2052 | if (defined $MUSIC_PLAYING) { |
2053 | if ($MUSIC_PLAYING) { |
2053 | warn "fade out"; |
2054 | warn "fade out"; |
2054 | CFPlus::MixMusic::fade_out 2000; |
2055 | CFPlus::MixMusic::fade_out 1500; |
2055 | } else { |
2056 | } else { |
2056 | warn "new music\n"; |
2057 | warn "new music\n"; |
2057 | |
2058 | |
2058 | my $music = $MUSIC_WANT [rand @MUSIC_WANT]; |
2059 | my $music = $MUSIC_WANT [rand @MUSIC_WANT]; |
2059 | |
2060 | |
2060 | $MUSIC_PLAYING = $music->{path}; |
2061 | $MUSIC_PLAYING = $music; |
2061 | |
2062 | |
2062 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path}; |
2063 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path}; |
2063 | $MUSIC_PLAYER->play (0); |
2064 | $MUSIC_PLAYER->play (0); |
2064 | } |
2065 | } |
2065 | } |
2066 | } |