Revert "spotify: Remove gst import from spotify.playback module"
This reverts commit b4028e9c57.
This commit is contained in:
parent
b4028e9c57
commit
ea431c2f18
@ -1,5 +1,9 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import pygst
|
||||||
|
pygst.require('0.10')
|
||||||
|
import gst
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
@ -35,7 +39,7 @@ class SpotifyPlaybackProvider(base.BasePlaybackProvider):
|
|||||||
self.backend.spotify.session.load(
|
self.backend.spotify.session.load(
|
||||||
Link.from_string(track.uri).as_track())
|
Link.from_string(track.uri).as_track())
|
||||||
self.backend.spotify.session.play(1)
|
self.backend.spotify.session.play(1)
|
||||||
self.backend.spotify.buffer_timestamp_in_ms = 0
|
self.backend.spotify.buffer_timestamp = 0
|
||||||
|
|
||||||
self.audio.prepare_change()
|
self.audio.prepare_change()
|
||||||
self.audio.set_appsrc(
|
self.audio.set_appsrc(
|
||||||
@ -55,5 +59,5 @@ class SpotifyPlaybackProvider(base.BasePlaybackProvider):
|
|||||||
|
|
||||||
def on_seek_data(self, time_position):
|
def on_seek_data(self, time_position):
|
||||||
logger.debug('playback.on_seek_data(%d) called', time_position)
|
logger.debug('playback.on_seek_data(%d) called', time_position)
|
||||||
self.backend.spotify.buffer_timestamp_in_ms = time_position
|
self.backend.spotify.buffer_timestamp = time_position * gst.MSECOND
|
||||||
self.backend.spotify.session.seek(time_position)
|
self.backend.spotify.session.seek(time_position)
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager):
|
|||||||
self.backend_ref = backend_ref
|
self.backend_ref = backend_ref
|
||||||
|
|
||||||
self.connected = threading.Event()
|
self.connected = threading.Event()
|
||||||
self.buffer_timestamp_in_ms = 0
|
self.buffer_timestamp = 0
|
||||||
|
|
||||||
self.container_manager = None
|
self.container_manager = None
|
||||||
self.playlist_manager = None
|
self.playlist_manager = None
|
||||||
@ -124,10 +124,10 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager):
|
|||||||
|
|
||||||
buffer_ = gst.Buffer(bytes(frames))
|
buffer_ = gst.Buffer(bytes(frames))
|
||||||
buffer_.set_caps(gst.caps_from_string(capabilites))
|
buffer_.set_caps(gst.caps_from_string(capabilites))
|
||||||
buffer_.timestamp = self.buffer_timestamp_in_ms * gst.MSECOND
|
buffer_.timestamp = self.buffer_timestamp
|
||||||
buffer_.duration = num_frames * gst.SECOND // sample_rate
|
buffer_.duration = num_frames * gst.SECOND / sample_rate
|
||||||
|
|
||||||
self.buffer_timestamp_in_ms += buffer_.duration // gst.MSECOND
|
self.buffer_timestamp += buffer_.duration
|
||||||
|
|
||||||
if self.audio.emit_data(buffer_).get():
|
if self.audio.emit_data(buffer_).get():
|
||||||
return num_frames
|
return num_frames
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user