コード例 #1
0
def pause_unpause(session_id=0):
    """
    This method is for pausing and un-pausing the alsaplayer
    :return: True if successfully paused or un-paused.
    """
    if alsaplayer.get_speed(session_id) == 0:
        return alsaplayer.unpause(session_id) == 1
    else:
        return alsaplayer.pause(session_id) == 1
コード例 #2
0
def pause_unpause(session_id=0):
    """
    This method is for pausing and un-pausing the alsaplayer
    :return: True if successfully paused or un-paused.
    """
    if alsaplayer.get_speed(session_id) == 0:
        return alsaplayer.unpause(session_id) == 1
    else:
        return alsaplayer.pause(session_id) == 1
コード例 #3
0
def get_status(session_id=0):
    """
    This method is to get the current status of the song playing
    :param session_id: Session ID
    :type session_id: int
    :return: dict
    """
    length = 0
    position = 0
    session_name = 'none'
    playlist_length = 0
    speed = 0
    volume_level = 1
    song_title = ''
    song_artist = ''
    song_album = ''
    try:
        length = alsaplayer.get_length(session_id)
        position = alsaplayer.get_position(session_id)
        session_name = alsaplayer.get_session_name(session_id)
        # playlist = alsaplayer.get_playlist(session_id)
        playlist_length = alsaplayer.get_playlist_length(session_id)
        speed = alsaplayer.get_speed(session_id)
        volume_level = float("%.2f" % alsaplayer.get_volume(session_id))
        song_title = alsaplayer.get_title(session_id)
        song_artist = alsaplayer.get_artist(session_id)
        song_album = alsaplayer.get_album(session_id)
    except Exception as e:
        app.logger.error(e)

    status = {
        "current_track": {
            "length_mins": conv_to_mins(length),
            "length": length,
            "position": position,
            "title": song_title,
            "album": song_album,
            "artist": song_artist
        },
        "session": {
            "name": session_name,
            "playlist_length": playlist_length,
            "speed": speed,
            "volume": volume_level
        }

    }
    status_dict = {'status': status}
    return status_dict
コード例 #4
0
def get_status(session_id=0):
    """
    This method is to get the current status of the song playing
    :param session_id: Session ID
    :type session_id: int
    :return: dict
    """
    length = 0
    position = 0
    session_name = 'none'
    playlist_length = 0
    speed = 0
    volume_level = 1
    song_title = ''
    song_artist = ''
    song_album = ''
    try:
        length = alsaplayer.get_length(session_id)
        position = alsaplayer.get_position(session_id)
        session_name = alsaplayer.get_session_name(session_id)
        # playlist = alsaplayer.get_playlist(session_id)
        playlist_length = alsaplayer.get_playlist_length(session_id)
        speed = alsaplayer.get_speed(session_id)
        volume_level = float("%.2f" % alsaplayer.get_volume(session_id))
        song_title = alsaplayer.get_title(session_id)
        song_artist = alsaplayer.get_artist(session_id)
        song_album = alsaplayer.get_album(session_id)
    except Exception as e:
        app.logger.error(e)

    status = {
        "current_track": {
            "length_mins": conv_to_mins(length),
            "length": length,
            "position": position,
            "title": song_title,
            "album": song_album,
            "artist": song_artist
        },
        "session": {
            "name": session_name,
            "playlist_length": playlist_length,
            "speed": speed,
            "volume": volume_level
        }
    }
    status_dict = {'status': status}
    return status_dict