Skip to content

Commit 86322c8

Browse files
authored
Add files via upload
1 parent 40f3ac2 commit 86322c8

File tree

6 files changed

+270
-66
lines changed

6 files changed

+270
-66
lines changed

LICENSE

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2023 FuLong97
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1+
MIT License
2+
3+
Copyright (c) 2023 FuLong97
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.

README.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
# Radio Stream Player Pywave Tunes
2-
3-
The Radio Stream Player is a Python application that allows users to play and control radio streams through a graphical user interface (GUI). It leverages the tkinter library for creating the GUI and the vlc library for handling media playback.
4-
5-
## Features
6-
7-
- Play radio streams from various sources.
8-
- Pause and resume playback.
9-
- Control volume using a slider.
10-
- Fetch metadata information, such as the current playing song, from the radio streams. // WIP
11-
- User-friendly interface with a sleek and modern design. //WIP
12-
13-
## Usage
14-
15-
1. Clone or download the repository to your local machine.
16-
2. Install the required dependencies listed in the `requirements.txt` file.
17-
3. Run the `radio_stream_player.py` script to launch the application.
18-
4. Select a radio stream from the available options.
19-
5. Use the play and pause buttons to control playback.
20-
6. Adjust the volume using the volume slider.
21-
7. The current playing song information will be displayed in real-time.
22-
23-
## Contributing
24-
25-
Contributions are welcome! If you would like to contribute to the Radio Stream Player, please follow these steps:
26-
27-
1. Fork the repository.
28-
2. Create a new branch for your feature or bug fix.
29-
3. Make your changes and test thoroughly.
30-
4. Commit your changes with descriptive commit messages.
31-
5. Push your changes to your forked repository.
32-
6. Submit a pull request to the main repository, detailing the changes you've made.
33-
34-
Please ensure that your code adheres to the existing coding style and conventions. Additionally, it's recommended to open an issue to discuss major changes or enhancements before working on them.
35-
36-
## License
37-
38-
The Radio Stream Player is open-source and released under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code for personal and commercial purposes.
39-
40-
## Acknowledgments
41-
42-
The Radio Stream Player was developed using the tkinter library for GUI and the vlc library for media playback. We extend our gratitude to the developers of these libraries for their excellent work.
43-
44-
If you have any questions, feedback, or suggestions, please don't hesitate to open an issue or contact the project maintainers.
45-
46-
Enjoy listening to your favorite radio streams with the Radio Stream Player!
1+
# Radio Stream Player
2+
3+
The Radio Stream Player is a Python application that allows users to play and control radio streams through a graphical user interface (GUI). It leverages the tkinter library for creating the GUI and the vlc library for handling media playback.
4+
5+
## Features
6+
7+
- Play radio streams from various sources.
8+
- Pause and resume playback.
9+
- Control volume using a slider.
10+
- Fetch metadata information, such as the current playing song, from the radio streams. // WIP
11+
- User-friendly interface with a sleek and modern design. //WIP
12+
13+
## Usage
14+
15+
1. Clone or download the repository to your local machine.
16+
2. Install the required dependencies listed in the `requirements.txt` file.
17+
3. Run the `radio_stream_player.py` script to launch the application.
18+
4. Select a radio stream from the available options.
19+
5. Use the play and pause buttons to control playback.
20+
6. Adjust the volume using the volume slider.
21+
7. The current playing song information will be displayed in real-time.
22+
23+
## Contributing
24+
25+
Contributions are welcome! If you would like to contribute to the Radio Stream Player, please follow these steps:
26+
27+
1. Fork the repository.
28+
2. Create a new branch for your feature or bug fix.
29+
3. Make your changes and test thoroughly.
30+
4. Commit your changes with descriptive commit messages.
31+
5. Push your changes to your forked repository.
32+
6. Submit a pull request to the main repository, detailing the changes you've made.
33+
34+
Please ensure that your code adheres to the existing coding style and conventions. Additionally, it's recommended to open an issue to discuss major changes or enhancements before working on them.
35+
36+
## License
37+
38+
The Radio Stream Player is open-source and released under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code for personal and commercial purposes.
39+
40+
## Acknowledgments
41+
42+
The Radio Stream Player was developed using the tkinter library for GUI and the vlc library for media playback. We extend our gratitude to the developers of these libraries for their excellent work.
43+
44+
If you have any questions, feedback, or suggestions, please don't hesitate to open an issue or contact the project maintainers.
45+
46+
Enjoy listening to your favorite radio streams with the Radio Stream Player!

Radio.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from tkinter import *
2+
from ttkbootstrap import *
3+
from ttkbootstrap.style import Style
4+
import ttkbootstrap as ttk
5+
import vlc
6+
from ttkbootstrap.constants import *
7+
from ttkbootstrap.toast import ToastNotification
8+
import requests
9+
import threading
10+
11+
player = None
12+
13+
def play_radio():
14+
global player
15+
stream = selected_stream.get()
16+
player = vlc.MediaPlayer(stream)
17+
player.play()
18+
19+
def pause_radio():
20+
global player
21+
player.stop()
22+
23+
def change_volume(event):
24+
global player
25+
volume = int(volume_slider.get())
26+
if player:
27+
player.audio_set_volume(volume)
28+
volume_percentage = volume / 100 # Calculate volume percentage
29+
volume_label.configure(text="Volume: {:.0%}".format(volume_percentage))
30+
31+
def fetch_radio_metadata():
32+
stream_url = selected_stream.get()
33+
while True:
34+
response = requests.get(stream_url, stream=True)
35+
if 'icy-metaint' in response.headers:
36+
metaint_header = int(response.headers['icy-metaint'])
37+
if metaint_header > 0:
38+
response.raw.read(metaint_header) # Discard audio data
39+
metadata_length = int(response.raw.read(1)[0]) * 16 # Metadata length
40+
if metadata_length > 0:
41+
metadata = response.raw.read(metadata_length).decode('utf-8')
42+
metadata = metadata.strip() # Remove leading/trailing whitespace
43+
if metadata.startswith('StreamTitle='):
44+
song_info = metadata.replace('StreamTitle=', '').strip("'").strip()
45+
# Update the label in the main GUI thread
46+
root.after_idle(lambda: current_song_label.configure(text="Current Song: " + song_info))
47+
48+
response.close()
49+
50+
51+
root = ttk.Window(themename="darkly")
52+
root.geometry("500x500")
53+
root.title("Radio")
54+
55+
volume_slider = ttk.Scale(root, from_=0, to=100, orient=tk.HORIZONTAL, length=400)
56+
volume_slider.set(100)
57+
volume_slider.pack(side=tk.TOP, padx=5, pady=5)
58+
59+
pause_button = ttk.Button(root, text='Pause', bootstyle=DARK, command=pause_radio)
60+
pause_button.pack(side=BOTTOM, padx=10, pady="10")
61+
62+
play_button = ttk.Button(root, text='Play', bootstyle=DARK, command=play_radio)
63+
play_button.pack(side=BOTTOM, padx=5, pady=10)
64+
65+
label = ttk.Label(root, text="PyWaveTunes", font=("Arial", 30))
66+
label.pack(side=TOP, padx=5, pady=5)
67+
68+
selected_stream = StringVar()
69+
streams = ["http://radio886.at/streams/radio_88.6/mp3", "http://radio886.at/streams/88.6_Classic_Rock/mp3"]
70+
stream_cb = ttk.Combobox(root, values=streams, textvariable=selected_stream, font=("Arial", 15), width=50, state="readonly")
71+
stream_cb.pack(side=TOP, padx=5, pady=50)
72+
73+
volume_label = ttk.Label(root, text="Volume:", font=("Arial", 15))
74+
volume_label.pack(side=TOP, padx=5, pady=5)
75+
76+
volume_slider.bind("<ButtonRelease-1>", change_volume)
77+
volume_slider.bind("<B1-Motion>", change_volume)
78+
stream_cb.bind("<<ComboboxSelected>>", change_volume)
79+
play_button.bind("<ButtonRelease-1>", change_volume)
80+
81+
tabControl = ttk.Notebook(root)
82+
tab1 = ttk.Frame(tabControl)
83+
tabControl.add(tab1, text="Streams")
84+
tabControl.pack(side="top", expand=1, fill="both")
85+
86+
tab2 = ttk.Frame(tabControl)
87+
tabControl.add(tab2, text="Settings")
88+
tabControl.pack(side="top", expand=1, fill="both")
89+
90+
current_stream_label = ttk.Label(tab1, text="Song: " + selected_stream.get(), font=("Arial", 15))
91+
current_stream_label.pack(padx=5, pady=5)
92+
current_song_label = ttk.Label(tab1, text="Current Song:", font=("Arial", 15))
93+
current_song_label.pack(padx=5, pady=5)
94+
95+
fetch_thread = threading.Thread(target=fetch_radio_metadata)
96+
fetch_thread.daemon = True
97+
fetch_thread.start()
98+
99+
root.mainloop()

links.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
http://live-radio02.mediahubaustralia.com/2FMW/mp3/
2+
http://live-radio02.mediahubaustralia.com/CTRW/mp3
3+
http://live-radio01.mediahubaustralia.com/DJDW/mp3
4+
http://live-radio01.mediahubaustralia.com/JAZW/mp3
5+
http://live-radio02.mediahubaustralia.com/PBW/mp3/
6+
http://live-radio01.mediahubaustralia.com/2TJW/mp3/

requirements.txt

4.29 KB
Binary file not shown.

tempCodeRunnerFile.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from tkinter import *
2+
from ttkbootstrap import *
3+
from ttkbootstrap.style import Style
4+
import ttkbootstrap as ttk
5+
import vlc
6+
from ttkbootstrap.constants import *
7+
from ttkbootstrap.toast import ToastNotification
8+
import requests
9+
import threading
10+
11+
player = None
12+
13+
def play_radio():
14+
global player
15+
stream = selected_stream.get()
16+
player = vlc.MediaPlayer(stream)
17+
player.play()
18+
19+
def pause_radio():
20+
global player
21+
player.stop()
22+
23+
def change_volume(event):
24+
global player
25+
volume = int(volume_slider.get())
26+
if player:
27+
player.audio_set_volume(volume)
28+
volume_percentage = volume / 100 # Calculate volume percentage
29+
volume_label.configure(text="Volume: {:.0%}".format(volume_percentage))
30+
31+
def fetch_radio_metadata():
32+
stream_url = selected_stream.get()
33+
while True:
34+
response = requests.get(stream_url, stream=True)
35+
if 'icy-metaint' in response.headers:
36+
metaint_header = int(response.headers['icy-metaint'])
37+
if metaint_header > 0:
38+
response.raw.read(metaint_header) # Discard audio data
39+
metadata_length = int(response.raw.read(1)[0]) * 16 # Metadata length
40+
if metadata_length > 0:
41+
metadata = response.raw.read(metadata_length).decode('utf-8')
42+
metadata = metadata.strip() # Remove leading/trailing whitespace
43+
if metadata.startswith('StreamTitle='):
44+
song_info = metadata.replace('StreamTitle=', '').strip("'").strip()
45+
# Update the label in the main GUI thread
46+
root.after_idle(lambda: current_song_label.configure(text="Current Song: " + song_info))
47+
48+
response.close()
49+
50+
51+
root = ttk.Window(themename="darkly")
52+
root.geometry("500x500")
53+
root.title("Radio")
54+
55+
volume_slider = ttk.Scale(root, from_=0, to=100, orient=tk.HORIZONTAL, length=400)
56+
volume_slider.set(100)
57+
volume_slider.pack(side=tk.TOP, padx=5, pady=5)
58+
59+
pause_button = ttk.Button(root, text='Pause', bootstyle=DARK, command=pause_radio)
60+
pause_button.pack(side=BOTTOM, padx=10, pady="10")
61+
62+
play_button = ttk.Button(root, text='Play', bootstyle=DARK, command=play_radio)
63+
play_button.pack(side=BOTTOM, padx=5, pady=10)
64+
65+
label = ttk.Label(root, text="PyWaveTunes", font=("Arial", 30))
66+
label.pack(side=TOP, padx=5, pady=5)
67+
68+
selected_stream = StringVar()
69+
streams = ["http://radio886.at/streams/radio_88.6/mp3", "http://radio886.at/streams/88.6_Classic_Rock/mp3"]
70+
stream_cb = ttk.Combobox(root, values=streams, textvariable=selected_stream, font=("Arial", 15), width=50, state="readonly")
71+
stream_cb.pack(side=TOP, padx=5, pady=50)
72+
73+
volume_label = ttk.Label(root, text="Volume:", font=("Arial", 15))
74+
volume_label.pack(side=TOP, padx=5, pady=5)
75+
76+
volume_slider.bind("<ButtonRelease-1>", change_volume)
77+
volume_slider.bind("<B1-Motion>", change_volume)
78+
stream_cb.bind("<<ComboboxSelected>>", change_volume)
79+
play_button.bind("<ButtonRelease-1>", change_volume)
80+
81+
tabControl = ttk.Notebook(root)
82+
tab1 = ttk.Frame(tabControl)
83+
tabControl.add(tab1, text="Streams")
84+
tabControl.pack(side="top", expand=1, fill="both")
85+
86+
tab2 = ttk.Frame(tabControl)
87+
tabControl.add(tab2, text="Settings")
88+
tabControl.pack(side="top", expand=1, fill="both")
89+
90+
current_stream_label = ttk.Label(tab1, text="Song: " + selected_stream.get(), font=("Arial", 15))
91+
current_stream_label.pack(padx=5, pady=5)
92+
current_song_label = ttk.Label(tab1, text="Current Song:", font=("Arial", 15))
93+
current_song_label.pack(padx=5, pady=5)
94+
95+
fetch_thread = threading.Thread(target=fetch_radio_metadata)
96+
fetch_thread.daemon = True
97+
fetch_thread.start()
98+
99+
root.mainloop()

0 commit comments

Comments
 (0)