Exemplo n.º 1
0
def play():
    global play_list
    # stop playback if active
    if play_list:
        play_list.stop()

    video = request.json.get('video')
    if video:
        play_list_videos = [request.json]
    else:
        play_list_videos = request.json.get('play_list')

    if play_list_videos:
        loop = request.json.get('loop', False)
        start_time = request.json.get('start_time')
        end_time = request.json.get('end_time')
        if start_time and end_time:
            schedule_show(start_time, end_time, play_list_videos, loop=loop)
            return flask.jsonify(status='scheduled')
        else:
            play_list = omx.PlayList(play_list_videos, loop=loop)
            play_list.play()
            return flask.jsonify(status='running')
    else:
        return flask.jsonify(status='stopped')
Exemplo n.º 2
0
def cache_files_task(play_list_entries):
    """
        Ensure all videos referenced in a play list are cached locally on the pi
    """
    try:
        play_list = omx.PlayList(play_list_entries)
        play_list.cache_entries()
        report_pi_status_task()
    except:
        logger.exception('Problem caching videos')
    else:
        # Once the videos have been cached, we'll cancel this task
        return schedule.CancelJob
Exemplo n.º 3
0
def showtime_task(play_list_entries, loop=False):
    """
        This task is used to kick off a show at a scheduled time.
        It is provided with play list data based on the Video Village Window API
        JSON.
    """
    global play_list
    global scheduled_show_active

    try:
        scheduled_show_active = True
        play_list = omx.PlayList(play_list_entries, loop=loop)
        play_list.play()
        report_pi_status_task()
    except:
        logger.exception('Problem starting scheduled play list')
    finally:
        # Once the show is going, we'll stop running this task
        return schedule.CancelJob