audio: Create a new BassPlayer class
My intention is to use this to handle GStreamer stuff so I can separate out the higher level functions like next(), previous(), and load_track() Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
94235b1ce8
commit
990a8047d9
|
@ -0,0 +1,11 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gst
|
||||
|
||||
class BassPlayer(GObject.GObject):
|
||||
def __init__(self):
|
||||
GObject.GObject.__init__(self)
|
||||
self.video = Gst.ElementFactory.make("fakesink")
|
||||
self.playbin = Gst.ElementFactory.make("playbin")
|
||||
self.playbin.set_property("video-sink", self.video)
|
||||
self.playbin.set_state(Gst.State.READY)
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import artwork
|
||||
from . import bass
|
||||
from . import scale
|
||||
from . import controls
|
||||
from lib import publisher
|
||||
|
@ -8,12 +9,10 @@ from gi.repository import GObject
|
|||
from gi.repository import Gst, GLib
|
||||
import tagdb
|
||||
|
||||
class Player(GObject.GObject):
|
||||
|
||||
class Player(bass.BassPlayer):
|
||||
def __init__(self):
|
||||
GObject.GObject.__init__(self)
|
||||
self.video = Gst.ElementFactory.make("fakesink")
|
||||
self.playbin = Gst.ElementFactory.make("playbin")
|
||||
self.playbin.set_property("video-sink", self.video)
|
||||
bass.BassPlayer.__init__(self)
|
||||
self.Autopause = scale.AutoPauseScale()
|
||||
|
||||
self.bus = self.playbin.get_bus()
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
import unittest
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gst
|
||||
from . import bass
|
||||
|
||||
class TestBassPlayer(unittest.TestCase):
|
||||
def test_bass_player_init(self):
|
||||
base = bass.BassPlayer()
|
||||
self.assertIsInstance(base, GObject.GObject)
|
||||
self.assertIsInstance(base.video, Gst.Element)
|
||||
self.assertIsInstance(base.playbin, Gst.Element)
|
||||
self.assertEqual(base.playbin.get_property("video-sink"), base.video)
|
||||
self.assertEqual(base.playbin.get_state(Gst.CLOCK_TIME_NONE)[1],
|
||||
Gst.State.READY)
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import artwork
|
||||
from . import bass
|
||||
from . import controls
|
||||
from . import nowplaying
|
||||
from . import player
|
||||
|
@ -42,16 +43,12 @@ class TestPlayer(unittest.TestCase):
|
|||
|
||||
def test_player_init(self):
|
||||
play = player.Player()
|
||||
self.assertIsInstance(play, GObject.GObject)
|
||||
self.assertIsInstance(play.video, Gst.Element)
|
||||
self.assertIsInstance(play.playbin, Gst.Element)
|
||||
self.assertIsInstance(play, bass.BassPlayer)
|
||||
self.assertIsInstance(play.bus, Gst.Bus)
|
||||
self.assertIsInstance(play.Artwork, artwork.Artwork)
|
||||
self.assertIsInstance(play.Autopause, scale.AutoPauseScale)
|
||||
self.assertIsNone(play.track)
|
||||
|
||||
self.assertEqual(play.playbin.get_property("video-sink"), play.video)
|
||||
|
||||
def test_player_load_track(self):
|
||||
play = player.Player()
|
||||
uri = test_track.absolute().as_uri()
|
||||
|
|
Loading…
Reference in New Issue