First commit.
Minimum viable product on both a command line video player and a gui player. Both need work and neither stream auido by default.
This commit is contained in:
commit
eb9115b486
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Audio Streamer
|
||||
|
||||
A python application to stream audio, primarily from YouTube, using MPV and YouTube-dl.
|
31
audio-streamer.py
Executable file
31
audio-streamer.py
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
import mpv
|
||||
import argparse
|
||||
import os
|
||||
|
||||
cmd_option_set = argparse.ArgumentParser(description='Stream Audio')
|
||||
cmd_option_set.add_argument('audio_stream_URL', type=str, help='URL of the audio you want streamed.')
|
||||
cmd_options = cmd_option_set.parse_args()
|
||||
|
||||
audio_stream = cmd_options.audio_stream_URL
|
||||
|
||||
|
||||
|
||||
if ( not audio_stream ):
|
||||
print ("No URL given\nPlease provide one.")
|
||||
os._exit(0)
|
||||
|
||||
audio_player = mpv.MPV(ytdl=True, input_default_bindings=True, input_vo_keyboard=True, osc=True)
|
||||
|
||||
@audio_player.on_key_press('q')
|
||||
def my_q_binding():
|
||||
print('THERE IS NO ESCAPE')
|
||||
|
||||
try:
|
||||
audio_player.play(audio_stream)
|
||||
audio_player.fullscreen
|
||||
audio_player.wait_for_playback()
|
||||
|
||||
del audio_player
|
||||
except mpv.ShutdownError:
|
||||
print("Playback has ended.")
|
55
gi-test.py
Executable file
55
gi-test.py
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
import gi
|
||||
|
||||
import mpv
|
||||
import locale
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
locale.setlocale(locale.LC_NUMERIC, 'C')
|
||||
class MainClass(Gtk.Window):
|
||||
|
||||
def __init__(self):
|
||||
super(MainClass, self).__init__()
|
||||
self.set_default_size(600, 400)
|
||||
self.connect("destroy", self.on_destroy)
|
||||
|
||||
widget = Gtk.Frame()
|
||||
|
||||
entry_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
||||
self.add(entry_container)
|
||||
self.entry_box = Gtk.Entry()
|
||||
entry_container.pack_start(self.entry_box, True, True, 0)
|
||||
play_button = Gtk.Button(label="Start")
|
||||
play_button.connect("clicked", self.on_play)
|
||||
entry_container.pack_start(play_button, True, True, 1)
|
||||
exit_btn = Gtk.Button(label="Exit")
|
||||
exit_btn.connect("clicked", self.on_destroy)
|
||||
entry_container.pack_start(exit_btn, True, True, 2)
|
||||
# ~ self.add(play_button)
|
||||
self.add(widget)
|
||||
self.show_all()
|
||||
# ~ @self.mpv.on_key_press('q')
|
||||
# ~ def my_q_binding():
|
||||
# ~ print('THERE IS NO ESCAPE')
|
||||
# ~ self.mpv.terminate()
|
||||
|
||||
|
||||
def on_play(self, widget):
|
||||
# Must be created >after< the widget is shown, else property 'window' will be None
|
||||
self.mpv = mpv.MPV(wid=str(widget.get_property("window").get_xid()), ytdl=True, input_default_bindings=True, input_vo_keyboard=True, osc=True)
|
||||
input_media = self.entry_box.get_text()
|
||||
|
||||
self.mpv.play(input_media)
|
||||
self.mpv.wait_for_playback()
|
||||
self.mpv.terminate()
|
||||
|
||||
def on_destroy(self, widget, data=None):
|
||||
#self.mpv.terminate()
|
||||
Gtk.main_quit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
application = MainClass()
|
||||
Gtk.main()
|
Loading…
x
Reference in New Issue
Block a user