Merge pull request #1040 from adamcik/fix/only-update-stream-title-for-streams

core: Only emit stream title changed for streams
This commit is contained in:
Stein Magnus Jodal 2015-03-15 21:27:50 +01:00
commit 5240b50f8b
3 changed files with 14 additions and 5 deletions

View File

@ -121,12 +121,16 @@ class Core(
return
tags = self.audio.get_current_tags().get()
if not tags or 'title' not in tags or not tags['title']:
if not tags:
return
title = tags['title'][0]
self.playback._stream_title = title
CoreListener.send('stream_title_changed', title=title)
# TODO: this limits us to only streams that set organization, this is
# a hack to make sure we don't emit stream title changes for plain
# tracks. We need a better way to decide if something is a stream.
if 'title' in tags and tags['title'] and 'organization' in tags:
title = tags['title'][0]
self.playback._stream_title = title
CoreListener.send('stream_title_changed', title=title)
class Backends(list):

View File

@ -593,6 +593,7 @@ class TestStream(unittest.TestCase):
def test_get_stream_title_during_playback_with_tags_change(self):
self.core.playback.play()
self.audio.trigger_fake_tags_changed({'organization': ['baz']})
self.audio.trigger_fake_tags_changed({'title': ['foobar']}).get()
self.replay_audio_events()
@ -600,6 +601,7 @@ class TestStream(unittest.TestCase):
def test_get_stream_title_after_next(self):
self.core.playback.play()
self.audio.trigger_fake_tags_changed({'organization': ['baz']})
self.audio.trigger_fake_tags_changed({'title': ['foobar']}).get()
self.core.playback.next()
@ -608,8 +610,10 @@ class TestStream(unittest.TestCase):
def test_get_stream_title_after_next_with_tags_change(self):
self.core.playback.play()
self.audio.trigger_fake_tags_changed({'organization': ['baz']})
self.audio.trigger_fake_tags_changed({'title': ['foo']}).get()
self.core.playback.next()
self.audio.trigger_fake_tags_changed({'organization': ['baz']})
self.audio.trigger_fake_tags_changed({'title': ['bar']}).get()
self.replay_audio_events()
@ -617,6 +621,7 @@ class TestStream(unittest.TestCase):
def test_get_stream_title_after_stop(self):
self.core.playback.play()
self.audio.trigger_fake_tags_changed({'organization': ['baz']})
self.audio.trigger_fake_tags_changed({'title': ['foobar']}).get()
self.core.playback.stop()

View File

@ -110,7 +110,7 @@ class DummyAudio(pykka.ThreadingActor):
self._state_change_result = False
def trigger_fake_tags_changed(self, tags):
self._tags = tags
self._tags.update(tags)
audio.AudioListener.send('tags_changed', tags=self._tags.keys())
def get_about_to_finish_callback(self):