Stream internet radio playlist with python-vlc

PHOTO EMBED

Mon Jan 31 2022 02:15:00 GMT+0000 (Coordinated Universal Time)

Saved by @aguest #python #music

"""
This example streams a playlist (.pls file) from an internet URL.
"""

import vlc


# URL to the .pls (playlist) file
playlist_url = "https://somafm.com/nossl/specials.pls"

# create a VLC instance and pass any VLC arguments you want to the new instance
# --intf dummy  is a dummy interface and this is used to run VLC in a headless mode
instance = vlc.Instance('--intf dummy')

player = instance.media_list_player_new()  # create a "media list" player for use with playlists

media = instance.media_list_new(playlist_url)  # create the media instance for the playlist

player.set_media_list(media)  # set what media instance you want to play

player.start()  # start the stream

player.pause()  # pause the stream

player.stop()  # stop the stream
content_copyCOPY