コード例 #1
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def play_announce():
    # write text file for announcer
    announce_text = open('announce.txt', 'w')
    announcer_contents(announce_text)
    announce_text.close()
    # make announce.wav using announcer program
    announcer = Popen(radio_settings.announcer, shell=True, stdin=PIPE)
    announcer_contents(announcer.stdin)
    announcer.stdin.close()
    # update title and pick bgm while we're waiting for announcer to finish
    icecast.update_metadata(radio_settings.announce_title)
    announce_bgm = os.path.join(
        radio_settings.announce_bgm_directory,
        choice(os.listdir(radio_settings.announce_bgm_directory)))
    announcer.wait()
    # play announce.wav mixed with bgm
    player = Popen([radio_settings.player, announce_bgm, "announce.wav"],
                   bufsize=4096,
                   stdout=PIPE).stdout
    print "announcement... %s %s %s" % (radio_settings.player, announce_bgm,
                                        "announce.wav")
    try:
        play_loop(player)
    finally:
        player.close()
コード例 #2
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def play_one_song(song, update_metadata=True):
    if update_metadata:
        icecast.update_metadata(get_metadata(song))
    player = Popen([radio_settings.player, song], bufsize=4096, stdout=PIPE).stdout
    print "playing %s..." % song
    try:
        play_loop(player)
    finally: # close the player when any exception is thrown
        player.close()
コード例 #3
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def play_one_song(song, update_metadata=True):
    if update_metadata:
        icecast.update_metadata(get_metadata(song))
    player = Popen([radio_settings.player, song], bufsize=4096,
                   stdout=PIPE).stdout
    print "playing %s..." % song
    try:
        play_loop(player)
    finally:  # close the player when any exception is thrown
        player.close()
コード例 #4
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def handle_messages():
    messages = radiocontrol.get_all_messages()
    for msg in messages:
        if msg[0] == "shutdown":
            raise ShutdownMessage
        elif msg[0] == "next_song":
            raise NextSongMessage
        elif msg[0] == "restart":
            raise RestartMessage
        elif msg[0] == "jump":
            if playlist.jump(msg[1]):
                raise RestartMessage
        elif msg[0] == "enqueue":
            if playlist.enqueue_after_current(msg[1]):
                raise RestartMessage
        elif msg[0] == "rescan":
            # the rescan is taking place in another thread
            # just start playing the song and then restart when it's done
            icecast.update_metadata(radio_settings.rescan_title)
            play_one_song(radio_settings.rescan_song, update_metadata=False)
            raise RestartMessage
コード例 #5
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def handle_messages():
    messages = radiocontrol.get_all_messages()
    for msg in messages:
        if msg[0] == "shutdown":
            raise ShutdownMessage
        elif msg[0] == "next_song":
            raise NextSongMessage
        elif msg[0] == "restart":
            raise RestartMessage       
        elif msg[0] == "jump":
            if playlist.jump(msg[1]):
                raise RestartMessage
        elif msg[0] == "enqueue":
            if playlist.enqueue_after_current(msg[1]):
                raise RestartMessage
        elif msg[0] == "rescan":
            # the rescan is taking place in another thread
            # just start playing the song and then restart when it's done
            icecast.update_metadata(radio_settings.rescan_title)
            play_one_song(radio_settings.rescan_song, update_metadata = False)
            raise RestartMessage
コード例 #6
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def play_announce():
    # write text file for announcer
    announce_text = open('announce.txt','w')
    announcer_contents(announce_text)
    announce_text.close()
    # make announce.wav using announcer program
    announcer = Popen(radio_settings.announcer, shell=True, stdin=PIPE)
    announcer_contents(announcer.stdin)
    announcer.stdin.close()
    # update title and pick bgm while we're waiting for announcer to finish
    icecast.update_metadata(radio_settings.announce_title)
    announce_bgm = os.path.join(radio_settings.announce_bgm_directory,
        choice(os.listdir(radio_settings.announce_bgm_directory)))
    announcer.wait()
    # play announce.wav mixed with bgm
    player = Popen([radio_settings.player, announce_bgm, "announce.wav"], bufsize=4096, stdout=PIPE).stdout
    print "announcement... %s %s %s" % (radio_settings.player, announce_bgm, "announce.wav")
    try:
        play_loop(player)
    finally:
        player.close()
コード例 #7
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def play_ident():
    icecast.update_metadata(radio_settings.ident_title)
    ident = os.path.join(radio_settings.ident_directory,
                         choice(os.listdir(radio_settings.ident_directory)))
    play_one_song(ident, update_metadata=False)
コード例 #8
0
ファイル: radio.py プロジェクト: nobuyukinyuu/doogradio
def play_ident():
    icecast.update_metadata(radio_settings.ident_title)
    ident = os.path.join(radio_settings.ident_directory,
        choice(os.listdir(radio_settings.ident_directory)))
    play_one_song(ident, update_metadata=False)