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


Python MediaDB.set_property方法代码示例

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


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

示例1: __on_tick

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def __on_tick(self, bin, pos, duration):        
     if self.song:
         if self.song.get_type() == "webcast":
             return
         
     pos /= 1000
     duration /= 1000
     
     if not duration or duration <= 0:
         return
     else:
         if not self.song.get("#duration") or self.song.get("#duration") != duration * 1000:
             if self.song.get_type() != "cue":
                 MediaDB.set_property(self.song, {"#duration": duration * 1000})
                 
     if self.song.get_type() == "cue":            
         duration = self.song.get("#duration") / 1000
         pos = pos - self.song.get("seek", 0)
             
     self.perhap_report(pos, duration)        # todo
     crossfade = self.get_crossfade()
     if crossfade < 0:
         crossfade = 0
     remaining = duration - pos    
     if crossfade:
         if remaining < crossfade:
             if not self.__next_already_called and remaining > 0:
                 self.logdebug("request new song: on tick and play-end not emit")
                 self.emit("play-end")                    
                 self.next()
                 self.__next_already_called = True
开发者ID:electricface,项目名称:deepin-music-player,代码行数:33,代码来源:__init__.py

示例2: update_skipcount

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def update_skipcount(self):        
     '''update skipcount.'''
     # if not played until the end
     if not self.song: return
     if self.song.get_type() != "local": return 
     if not self.__current_song_reported and self.song:
         MediaDB.set_property(self.song, {"#skipcount":self.song.get("#skipcount", 0) + 1})
开发者ID:electricface,项目名称:deepin-music-player,代码行数:9,代码来源:__init__.py

示例3: __on_tag

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def __on_tag(self, bin, taglist):    
     ''' The playbin found the tag information'''
     if not self.song: return 
     if not self.song.get("title") and self.song.get_type() not in ["cue", "cdda", "webcast", "local"]:
         self.logdebug("tag found %s", taglist)
         IDS = {
             "title": "title",
             "genre": "genre",
             "artist": "artist",
             "album": "album",
             "bitrate": "#bitrate",
             'track-number':"#track"
         }
         mod = {}
         for key in taglist.keys():
             if IDS.has_key(key):
                 if key == "lenght":
                     value = int(taglist[key]) * 1000
                 elif key == "bitrate":    
                     value = int(taglist[key] / 100)
                 elif isinstance(taglist[key], long):
                     value = int(taglist[key])
                 else:    
                     value = fix_charset(taglist[key])
                 mod[IDS[key]] = value
         MediaDB.set_property(self.song, mod)        
开发者ID:electricface,项目名称:deepin-music-player,代码行数:28,代码来源:__init__.py

示例4: remove_cover

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def remove_cover(self, song, emit=False):
     image_path = self.get_cover_path(song)
     if os.path.exists(image_path):    
         try:
             os.unlink(image_path)
         except:    
             pass
     if emit:    
         MediaDB.set_property(song, {"album" : song.get("album")})
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:11,代码来源:cover_manager.py

示例5: perhap_report

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def perhap_report(self, pos=None, duration=None):
     '''report song'''
     if not duration:
         duration = self.get_length()
     if not pos:    
         pos = self.get_position()
     if self.song and not self.__current_stream_seeked and not self.__next_already_called and not self.__current_song_reported and duration > 10 and pos and pos >= min(duration / 2, 240 * 1000):    
         MediaDB.set_property(self.song, {"#playcount": self.song.get("#playcount", 0) + 1})
         MediaDB.set_property(self.song, {"#lastplayed":time()})
         self.__current_song_reported = True
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:12,代码来源:__init__.py

示例6: get_length

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def get_length(self):
     '''get lenght'''
     if self.song is not None:
         duration = self.bin.xfade_get_duration()
         if duration != -1:
             # if current song_dict not have '#duration' and set it
             if not self.song.get("#duration"):
                 MediaDB.set_property(self.song, {"#duration": duration * 1000})
             return duration    
         elif self.song.get("#duration"):
             return self.song.get("#duration") / 1000
     return 0    
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:14,代码来源:__init__.py

示例7: change_cover

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def change_cover(self, song, new_cover):        
     save_path = self.get_cover_path(song)
     if not os.path.exists(new_cover):
         return False
     try:
         pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(new_cover, COVER_SAVE_SIZE["x"], COVER_SAVE_SIZE["y"])
     except gobject.GError:    
         return False
     else:
         str_pixbuf = pixbuf.get_pixels()
         if str_pixbuf.count("\x00") > len(str_pixbuf)/2 or str_pixbuf.count("\xff") > len(str_pixbuf)/2 : 
             return False
         else:
             if os.path.exists(save_path): os.unlink(save_path)
             pixbuf.save(save_path, "jpeg", {"quality":"85"})
             del pixbuf  
             
             # Change property album to update UI
             MediaDB.set_property(song, {"album" : song.get("album")})
             return True
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:22,代码来源:cover_manager.py

示例8: cleanup_cover

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def cleanup_cover(self, song, old_path, path=None):    
     if not path:
         path = old_path
     if not os.path.exists(old_path):    
         return False
     
     try:
         pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(old_path, COVER_SAVE_SIZE["x"], COVER_SAVE_SIZE["y"])
     except gobject.GError:    
         return False
     else:
         # Check cover is not a big black image
         str_pixbuf = pixbuf.get_pixels()
         if str_pixbuf.count("\x00") > len(str_pixbuf)/2 or str_pixbuf.count("\xff") > len(str_pixbuf)/2 : 
             return False
         else:
             if os.path.exists(path): os.unlink(path)
             pixbuf.save(path, "jpeg", {"quality":"85"})
             del pixbuf  
             
             # Change property album to update UI
             MediaDB.set_property(song, {"album" : song.get("album")})
             return True
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:25,代码来源:cover_manager.py

示例9: save_taginfo

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def save_taginfo(self, widget):    
     tags_modifiable = {}
     new_title = self.title_entry.get_text()
     new_artist = self.artist_entry.get_text()
     new_album = self.album_entry.get_text()
     new_genre = self.genre_entry.get_text()
     new_date = self.date_entry.get_text()
     
     db_song = MediaDB.get_song(self.song.get("uri"))
     
     if new_title != db_song.get_str("title"):
         tags_modifiable.update({"title" : new_title})
     if new_artist != db_song.get_str("artist"):
         tags_modifiable.update({"artist" : new_artist})
     if new_album != db_song.get_str("album"):
         tags_modifiable.update({"album" : new_album})
     if new_genre != db_song.get_str("genre"):
         tags_modifiable.update({"genre" : new_genre})
     if new_date != db_song.get_str("date"):    
         tags_modifiable.update({"date" : new_date})
         
     if tags_modifiable:    
         MediaDB.set_property(db_song, tags_modifiable, write_to_file=True)
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:25,代码来源:song_editor.py

示例10: __on_tick

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def __on_tick(self, bin, pos, duration):        
     if not duration or duration <= 0:
         return
     else:
         if not self.song.get("#duration") or self.song.get("#duration") != duration * 1000:
             MediaDB.set_property(self.song, {"#duration": duration * 1000})
             
     self.perhap_report(pos, duration)        # todo
     crossfade = self.get_crossfade()
     if crossfade < 0:
         crossfade = 0
     remaining = duration - pos    
     if crossfade:
         if remaining < crossfade:
             if not self.__next_already_called and remaining > 0:
                 self.logdebug("request new song: on tick and play-end not emit")
                 self.next()
                 self.emit("play-end")
                 self.__next_already_called = True
         else:        
             self.__next_already_called = False
     else:        
         self.__next_already_called = False
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:25,代码来源:__init__.py

示例11: fetch_cover

# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import set_property [as 别名]
 def fetch_cover(self, song):        
     success = self.get_cover(song, try_web=True, read_local=False)
     if success:
         Dispatcher.emit("album-changed", song)
         MediaDB.set_property(song, {"album" : song.get("album")})
开发者ID:electricface,项目名称:deepin-music-player,代码行数:7,代码来源:cover_manager.py


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