Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Playing music from streaming
#1
Hi,

I use the code below to play mp3 files but, how do I play a streaming site like this one: http://icy-4.radioparadise.com/aac-128

TIA


#!/usr/bin/python3

from __future__ import print_function
import logging
import pygame

logging.basicConfig(filename='/home/pi/proj/musicfile.log',level=logging.DEBUG)

#music files path
song = "music.mp3"

pygame.init()
pygame.mixer.init()

def play_song():
   try:
       #pygame.mixer.music.set_volume(0.50)
       pygame.mixer.music.load(song)
       pygame.mixer.music.play()
       clock = pygame.time.Clock()
       clock.tick(10)
       while pygame.mixer.music.get_busy():
           pygame.time.Clock().tick(10)
   except Exception as e:
        logging.exception("msg from music.py " + str(e))
        # Logs the error appropriately.
        raise

if __name__ == '__main__':
    while True:
        play_song()
Quote
#2
I would just call ffplay a part of FFmpeg.
This works.
import subprocess

stream = 'http://icy-4.radioparadise.com/aac-128'
subprocess.run(['ffplay', stream])
Libraries pydub, python-vlc, ffmpeg-python
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python 3.5 streaming output to the same log file that I write to cbj0517 2 447 Apr-23-2019, 04:38 PM
Last Post: cbj0517
  Streaming to website instead of Window OpenCV SDGRIFFUSW 1 337 Apr-19-2019, 09:59 PM
Last Post: SheeppOSU
  Playing mp3 file to specific device treii28 3 428 Mar-26-2019, 04:02 PM
Last Post: Larz60+
  run code while playing video almulder 0 490 Aug-26-2018, 07:19 PM
Last Post: almulder
  Python and SQL BLOB Streaming ashtona 4 1,023 May-09-2018, 06:13 PM
Last Post: ashtona
  Playing mp3 from variable mstone326 2 1,151 Aug-31-2017, 11:48 AM
Last Post: mstone326
  Pausing and playing a while loop. traceon 1 1,393 Jan-24-2017, 09:11 PM
Last Post: wavic
  Video Streaming Python 3 adaptation failling maimonid 8 3,527 Dec-28-2016, 09:20 AM
Last Post: maimonid

Forum Jump:


Users browsing this thread: 1 Guest(s)