Commit 0bbbd265 authored by Thorfin89's avatar Thorfin89

Ajout de la commande Play

parent e2723ef3
......@@ -2,17 +2,34 @@
# Fichier : main.py
# Auteur : Daniel SAZERAT (thorfin89@free.fr)
# Doc python-vlc
# https://www.olivieraubert.net/vlc/python-ctypes/doc/vlc.MediaPlayer-class.html
# https://stackoverflow.com/questions/46758360/how-to-play-streaming-audio-from-internet-radio-on-python-3-5-3
# import ----------------------------------
from rw_pupitre import Pupitre
import vlc # sudo pip3 install python-vlc
import time
# classes ---------------------------------
class Radio(Pupitre):
def __init__(self):
super().__init__() # constructeur de la classe parente
self.instance = vlc.Instance()
def radio_play(self):
player = self.instance.media_player_new()
media = self.instance.media_new("http://live.leanstream.co/CJOTFM-MP3")
player.set_media(media)
player.play()
time.sleep(10)
player.stop()
def radio_stop(self):
pass
app = Radio() # instancie l'application
app.boucle()
......@@ -9,6 +9,7 @@
# import ----------------------------------
import tkinter as tk
from tkinter import ttk
# classes ---------------------------------
......@@ -19,18 +20,29 @@ class Pupitre:
self.root.title("Web Radio Pi")
self.root.geometry("800x480")
self.root.resizable(width=False, height=False)
# Fenêtre Haute : Titre / Menu
self.bandeau = tk.Frame(self.root, width="800", height="80", bg="#8D8D8D")
self.bandeau.grid(row=0, column=0, columnspan=2)
# Fenêtre contenant les boutons (vignettes) des radios
self.cadreVignettes = tk.Frame(self.root, width="500", height="400", bg="#000000")
self.cadreVignettes.grid(row=1, column=0)
# Fenêtre d'affichage de la radio en cours de lecture, et des boutons de commande
self.cadreMenu = tk.Frame(self.root, width="300", height="400", bg="#BFBFBF")
self.cadreMenu.grid(row=1, column=1)
self.root.attributes('-fullscreen', False) # < A basculer sur False pour les test sur PC
self.zones()
def boucle(self):
self.root.mainloop()
def zones(self):
pass
# fenêtre Haute : Titre / Menu
bandeau = tk.Frame(self.root, width="800", height="80", bg="#8D8D8D")
bandeau.grid(row=0, column=0, columnspan=2)
# fenêtre contenant les boutons (vignettes) des radios
vignettes = tk.Frame(self.root, width="500", height="400", bg="#000000")
vignettes.grid(row=1, column=0)
# fenêtre d'affichage de la radio en cours de lecture, et des boutons de commande
menu = tk.Frame(self.root, width="300", height="400", bg="#BFBFBF")
menu.grid(row=1, column=1)
# affichage de la radio en cours de lecture
lbl_radio = tk.Label(bandeau, text="RADIO")
lbl_radio.pack(padx=20, pady=10)
# boutons de commande
btn_play = ttk.Button(menu, text="Play", command=self.radio_play)
btn_play.pack()
btn_pause = ttk.Button(menu, text="Pause", command=None)
btn_pause.pack()
btn_stop = ttk.Button(menu, text="Stop", command=self.radio_stop)
btn_stop.pack()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment