当前位置: 首页>>代码示例>>Python>>正文


Python Track.set_radio方法代码示例

本文整理汇总了Python中lollypop.objects.Track.set_radio方法的典型用法代码示例。如果您正苦于以下问题:Python Track.set_radio方法的具体用法?Python Track.set_radio怎么用?Python Track.set_radio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.objects.Track的用法示例。


在下文中一共展示了Track.set_radio方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prev

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def prev(self):
        """
            Return prev radio name, uri
            @return Track
        """
        track = Track()
        if self.current_track.id != Type.RADIOS:
            return track

        radios_manager = RadiosManager()
        radios = radios_manager.get()
        i = len(radios) - 1
        for (radio_id, name) in reversed(radios):
            i -= 1
            if self.current_track.album_artist == name:
                break

        # Get prev radio
        if i < 0:
            i = len(radios) - 1

        name = radios[i][1]
        uris = radios_manager.get_tracks(name)
        if len(uris) > 0:
            track.set_radio(name, uris[0])
        return track
开发者ID:ktosiu,项目名称:lollypop,代码行数:28,代码来源:player_radio.py

示例2: next

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def next(self):
        """
            Return next radio name, uri
            @return Track
        """
        track = Track()
        if self.current_track.id != Type.RADIOS:
            return track

        radios_manager = Radios()
        radios = radios_manager.get()
        i = 0
        for (name, url) in radios:
            i += 1
            if self.current_track.album_artist == name:
                break

        # Get next radio
        if i >= len(radios):
            i = 0

        name = radios[i][0]
        url = radios[i][1]
        if url:
            track.set_radio(name, url)
        return track
开发者ID:lesthack,项目名称:lollypop,代码行数:28,代码来源:player_radio.py

示例3: next

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def next(self):
        """
            Return next radio name, uri
            @return Track
        """
        track = Track()
        if self.current_track.id != Type.RADIOS:
            return track

        radios_manager = RadiosManager()
        radios = radios_manager.get()
        i = 0
        for (radio_id, name) in radios:
            i += 1
            if self.current_track.album_artist == name:
                break

        # Get next radio
        if i >= len(radios):
            i = 0

        name = radios[i][1]
        uris = radios_manager.get_tracks(name)
        if len(uris) > 0:
            track.set_radio(name, uris[0])
        return track
开发者ID:ktosiu,项目名称:lollypop,代码行数:28,代码来源:player_radio.py

示例4: __init__

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def __init__(self, name, radios_manager):
        """
            Init Popover
            @param name as string
            @param radios_manager as RadiosManager
        """
        Gtk.Popover.__init__(self)
        self.connect('map', self.__on_map)
        self.connect('unmap', self.__on_unmap)
        self.__name = name
        self.__radios_manager = radios_manager
        self.__start = 0
        self.__orig_pixbufs = {}

        self.__stack = Gtk.Stack()
        self.__stack.set_transition_duration(1000)
        self.__stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self.__stack.show()

        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadioPopover.ui')
        builder.connect_signals(self)

        self.__view = Gtk.FlowBox()
        self.__view.set_selection_mode(Gtk.SelectionMode.NONE)
        self.__view.connect('child-activated', self.__on_activate)
        self.__view.set_max_children_per_line(100)
        self.__view.set_property('row-spacing', 10)
        self.__view.show()

        builder.get_object('viewport').add(self.__view)

        self.__name_entry = builder.get_object('name')
        self.__uri_entry = builder.get_object('uri')
        self.__btn_add_modify = builder.get_object('btn_add_modify')
        self.__spinner = builder.get_object('spinner')
        self.__stack.add_named(builder.get_object('spinner-grid'), 'spinner')
        self.__stack.add_named(builder.get_object('notfound'), 'notfound')
        self.__stack.add_named(builder.get_object('logo'), 'logo')
        self.__stack.add_named(builder.get_object('widget'), 'widget')
        self.__stack.set_visible_child_name('widget')
        self.add(self.__stack)

        track = Track()
        track.set_radio(name, '')
        rating = RatingWidget(track)
        rating.show()
        builder.get_object('widget').attach(rating, 0, 2, 2, 1)

        if self.__name == '':
            # Translators: radio context
            builder.get_object('btn_add_modify').set_label(_("Add"))
        else:
            # Translators: radio context
            builder.get_object('btn_add_modify').set_label(_("Modify"))
            builder.get_object('btn_delete').show()
            self.__name_entry.set_text(self.__name)
            url = self.__radios_manager.get_url(self.__name)
            if url:
                self.__uri_entry.set_text(url)
开发者ID:blackjackshellac,项目名称:lollypop,代码行数:62,代码来源:pop_radio.py

示例5: __init__

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def __init__(self, name, radios_manager):
        """
            Init Popover
            @param name as string
            @param radios_manager as RadiosManager
        """
        Gtk.Popover.__init__(self)
        self.connect("map", self._on_map)
        self.connect("unmap", self._on_unmap)
        self._name = name
        self._radios_manager = radios_manager
        self._start = 0
        self._orig_pixbufs = {}

        self._stack = Gtk.Stack()
        self._stack.set_transition_duration(1000)
        self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self._stack.show()

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/RadioPopover.ui")
        builder.connect_signals(self)

        self._view = Gtk.FlowBox()
        self._view.set_selection_mode(Gtk.SelectionMode.NONE)
        self._view.connect("child-activated", self._on_activate)
        self._view.set_max_children_per_line(100)
        self._view.set_property("row-spacing", 10)
        self._view.show()

        builder.get_object("viewport").add(self._view)

        self._name_entry = builder.get_object("name")
        self._uri_entry = builder.get_object("uri")
        self._btn_add_modify = builder.get_object("btn_add_modify")
        self._spinner = builder.get_object("spinner")
        self._stack.add_named(builder.get_object("spinner-grid"), "spinner")
        self._stack.add_named(builder.get_object("notfound"), "notfound")
        self._stack.add_named(builder.get_object("logo"), "logo")
        self._stack.add_named(builder.get_object("widget"), "widget")
        self._stack.set_visible_child_name("widget")
        self.add(self._stack)

        track = Track()
        track.set_radio(name, "")
        rating = RatingWidget(track)
        rating.show()
        builder.get_object("widget").attach(rating, 0, 2, 2, 1)

        if self._name == "":
            builder.get_object("btn_add_modify").set_label(_("Add"))
        else:
            builder.get_object("btn_add_modify").set_label(_("Modify"))
            builder.get_object("btn_delete").show()
            self._name_entry.set_text(self._name)
            url = self._radios_manager.get_url(self._name)
            if url:
                self._uri_entry.set_text(url)
开发者ID:yogurt1,项目名称:lollypop,代码行数:60,代码来源:pop_radio.py

示例6: restore_state

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
 def restore_state(self):
     """
         Restore player state
     """
     if Lp().settings.get_value('save-state'):
         track_id = Lp().settings.get_value('track-id').get_int32()
         playlist_ids = Lp().settings.get_value('playlist-ids')
         if playlist_ids and playlist_ids[0] == Type.RADIOS:
             radios = Radios()
             track = Track()
             name = radios.get_name(track_id)
             url = radios.get_url(name)
             track.set_radio(name, url)
             self.load(track)
         elif Lp().tracks.get_path(track_id) != "":
             track = Track(track_id)
             self._load_track(track)
             if playlist_ids:
                 try:
                     pids = []
                     for playlist_id in playlist_ids:
                         pids.append(int(playlist_id))
                     track_ids = []
                     for playlist_id in playlist_ids:
                         if playlist_id == Type.POPULARS:
                             tracks = Lp().tracks.get_populars()
                         elif playlist_id == Type.RECENTS:
                             tracks = Lp().tracks.get_recently_listened_to()
                         elif playlist_id == Type.NEVER:
                             tracks = Lp().tracks.get_never_listened_to()
                         elif playlist_id == Type.RANDOMS:
                             tracks = Lp().tracks.get_randoms()
                         else:
                             tracks = Lp().playlists.get_tracks_ids(
                                                                playlist_id)
                         for track_id in tracks:
                             if track_id not in track_ids:
                                 track_ids.append(track_id)
                         self.populate_user_playlist_by_tracks(track_ids,
                                                               pids)
                 except:
                     pass  # User set non int in gsettings
             else:
                 self._albums = Lp().artists.get_albums(
                                                     track.album_artist_ids)
                 for album_id in self._albums:
                     self.context.genre_ids[album_id] = []
                     self.context.artist_ids[album_id] = []
             self.set_next()
             self.set_prev()
             if Lp().settings.get_value('repeat'):
                 self.context.next = NextContext.NONE
             else:
                 self.context.next = NextContext.STOP_ALL
             self.emit('current-changed')
         else:
             print("Player::restore_state(): track missing")
开发者ID:thinkking,项目名称:lollypop,代码行数:59,代码来源:player.py

示例7: _on_play_press_event

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
 def _on_play_press_event(self, widget, event):
     """
         Play radio
         @param: widget as Gtk.EventBox
         @param: event as Gdk.Event
     """
     url = self._radios_manager.get_url(self._name)
     if url:
         track = Track()
         track.set_radio(self._name, url)
         Lp().player.load(track)
开发者ID:WildAndrewLee,项目名称:lollypop,代码行数:13,代码来源:widgets_radio.py

示例8: _on_album_activated

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
 def _on_album_activated(self, flowbox, child):
     """
         Play album
         @param flowbox as Gtk.Flowbox
         @child as Gtk.FlowboxChild
     """
     name = child.get_child().get_name()
     url = self._radios_manager.get_url(name)
     if url:
         track = Track()
         track.set_radio(name, url)
         Lp().player.load(track)
开发者ID:kmf,项目名称:lollypop,代码行数:14,代码来源:view_radios.py

示例9: _on_album_activated

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
 def _on_album_activated(self, flowbox, child):
     """
         Play album
         @param flowbox as Gtk.Flowbox
         @child as Gtk.FlowboxChild
     """
     name = child.get_child().get_name()
     uris = self._radios_manager.get_tracks(name)
     if len(uris) > 0:
         track = Track()
         track.set_radio(name, uris[0])
         Lp.player.load(track)
开发者ID:ktosiu,项目名称:lollypop,代码行数:14,代码来源:view_radios.py

示例10: prev

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def prev(self):
        """
            Return prev radio name, uri
            @return Track
        """
        track = Track()
        if self._current_track.id != Type.RADIOS or not self.__radios:
            return track

        i = len(self.__radios) - 1
        for (name, url) in reversed(self.__radios):
            i -= 1
            if self._current_track.album_artists[0] == name:
                break

        # Get prev radio
        if i < 0:
            i = len(self.__radios) - 1

        name = self.__radios[i][0]
        url = self.__radios[i][1]
        if url:
            track.set_radio(name, url)
        return track
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:26,代码来源:player_radio.py

示例11: next

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
    def next(self):
        """
            Return next radio name, uri
            @return Track
        """
        track = Track()
        if self._current_track.id != Type.RADIOS or not self.__radios:
            return track

        i = 0
        for (name, url) in self.__radios:
            i += 1
            if self._current_track.album_artists[0] == name:
                break

        # Get next radio
        if i >= len(self.__radios):
            i = 0

        name = self.__radios[i][0]
        url = self.__radios[i][1]
        if url:
            track.set_radio(name, url)
        return track
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:26,代码来源:player_radio.py

示例12: restore_state

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_radio [as 别名]
 def restore_state(self):
     """
         Restore player state
     """
     try:
         if Lp().settings.get_value('save-state'):
             track_id = load(open(DataPath + "/track_id.bin", "rb"))
             playlist_ids = load(open(DataPath + "/playlist_ids.bin",
                                 "rb"))
             if playlist_ids and playlist_ids[0] == Type.RADIOS:
                 radios = Radios()
                 track = Track()
                 name = radios.get_name(track_id)
                 url = radios.get_url(name)
                 track.set_radio(name, url)
                 self.load(track)
             elif Lp().tracks.get_path(track_id) != "":
                 track = Track(track_id)
                 if Lp().notify is not None:
                     Lp().notify.inhibit()
                 self._load_track(track)
                 # We set this initial state
                 # because seek while failed otherwise
                 self.pause()
                 if playlist_ids:
                     pids = []
                     for playlist_id in playlist_ids:
                         pids.append(int(playlist_id))
                     track_ids = []
                     for playlist_id in playlist_ids:
                         if playlist_id == Type.POPULARS:
                             tracks = Lp().tracks.get_populars()
                         elif playlist_id == Type.RECENTS:
                             tracks = Lp().tracks.get_recently_listened_to()
                         elif playlist_id == Type.NEVER:
                             tracks = Lp().tracks.get_never_listened_to()
                         elif playlist_id == Type.RANDOMS:
                             tracks = Lp().tracks.get_randoms()
                         else:
                             tracks = Lp().playlists.get_track_ids(
                                                                playlist_id)
                         for track_id in tracks:
                             if track_id not in track_ids:
                                 track_ids.append(track_id)
                         self.populate_user_playlist_by_tracks(track_ids,
                                                               pids)
                 else:
                     self._albums = load(open(
                                         DataPath + "/albums.bin",
                                         "rb"))
                     self.shuffle_albums(True)
                     self._context.genre_ids = load(open(
                                         DataPath + "/genre_ids.bin",
                                         "rb"))
                     self._context.artist_ids = load(open(
                                         DataPath + "/artist_ids.bin",
                                         "rb"))
                 self.set_next()
                 self.set_prev()
                 if Lp().settings.get_value('repeat'):
                     self._context.next = NextContext.NONE
                 else:
                     self._context.next = NextContext.STOP_ALL
             else:
                 print("Player::restore_state(): track missing")
     except Exception as e:
         print("Player::restore_state()", e)
开发者ID:ferranroig,项目名称:lollypop,代码行数:69,代码来源:player.py


注:本文中的lollypop.objects.Track.set_radio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。