'Set track metadata for currently playing song.
Only needs to be called by sources such as ``appsrc`` which do not
already inject tags in playbin, e.g. when using :meth:`emit_data` to
deliver raw audio data to GStreamer.
:param track: the current track
:type track: :class:`mopidy.models.Track`'

def set_metadata(self, track):

    taglist = Gst.TagList.new_empty()
    artists = [a for a in (track.artists or []) if a.name]
    def set_value(tag, value):
        gobject_value = GObject.Value()
        gobject_value.init(GObject.TYPE_STRING)
        gobject_value.set_string(value)
        taglist.add_value(Gst.TagMergeMode.REPLACE, tag, gobject_value)
    set_value(Gst.TAG_ARTIST, u'    ')
    set_value(Gst.TAG_TITLE, u'    ')
    set_value(Gst.TAG_ALBUM, u'    ')
    if artists:
        set_value(Gst.TAG_ARTIST, u',    '.join([a.name for a in artists]))
    if track.name:
        set_value(Gst.TAG_TITLE, track.name)
    if (track.album and track.album.name):
        set_value(Gst.TAG_ALBUM, track.album.name)
    gst_logger.debug(u'Sending    TAG    event    for    track    %r:    %r', track.uri, taglist.to_string())
    event = Gst.Event.new_tag(taglist)
    if self._pending_uri:
        self._pending_metadata = event
    else:
        self._playbin.send_event(event)
