本文整理汇总了Python中xbmc.Player方法的典型用法代码示例。如果您正苦于以下问题:Python xbmc.Player方法的具体用法?Python xbmc.Player怎么用?Python xbmc.Player使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmc
的用法示例。
在下文中一共展示了xbmc.Player方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deleteFile
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def deleteFile(filename):
log('Deleting %s' % filename)
if len(filename) < 1:
log('Empty filename')
return
try: current = xbmc.Player().getPlayingFile() if xbmc.Player().isPlaying() else ''
except: current = ''
while current == filename:
try: current = xbmc.Player().getPlayingFile() if xbmc.Player().isPlaying() else ''
except: current = ''
xbmc.sleep(1000)
tries = 15
while xbmcvfs.exists(filename) and tries > 0:
tries -= 1
try:
xbmcvfs.delete(filename)
except Exception, e:
log('ERROR %s in deleteFile %s' % (str(e), filename))
log('ERROR tries=%d' % tries)
xbmc.sleep(500)
示例2: play
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def play(url, id=0):
print url
engine=__settings__.getSetting("Engine")
if engine=="0":
play_ace(url, id)
if engine=="1":
item = xbmcgui.ListItem()#path=url
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
tthp.play(url, handle, id, __settings__.getSetting("DownloadDirectory"))
if engine=="2":
purl ="plugin://plugin.video.yatp/?action=play&torrent="+ urllib.quote_plus(url)+"&file_index="+str(id)
item = xbmcgui.ListItem()#path=purl
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
xbmc.Player().play(purl)
示例3: play_video
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def play_video(video_url = common.args.url):
hbitrate = -1
sbitrate = int(addon.getSetting('quality')) * 1024
closedcaption = None
video_data = connection.getURL(video_url)
video_tree = BeautifulSoup(video_data, 'html.parser')
finalurl = video_tree.video['src']
try:
closedcaption = video_tree.find('textstream', type = 'text/vtt')['src']
except:
pass
if (addon.getSetting('enablesubtitles') == 'true') and (closedcaption is not None):
convert_subtitles(closedcaption)
xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
if (addon.getSetting('enablesubtitles') == 'true') and (closedcaption is not None):
while not xbmc.Player().isPlaying():
xbmc.sleep(100)
xbmc.Player().setSubtitles(ustvpaths.SUBTITLE)
示例4: done
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def done(title, dest, downloaded):
playing = xbmc.Player().isPlaying()
text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED')
if len(text) > 0:
text += '[CR]'
if downloaded:
text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]')
else:
text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR red]Download failed[/COLOR]')
xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text)
if (not downloaded) or (not playing):
xbmcgui.Dialog().ok(title, text)
xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
示例5: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def __init__ (self):
xbmc.Player.__init__(self)
log('Player - init')
self.token = __addon__.getSetting('token')
self.facebook = __addon__.getSetting('facebook')
self.twitter = __addon__.getSetting('twitter')
self.welcome = __addon__.getSetting('welcome')
self.notifications = __addon__.getSetting('notifications')
self.notif_during_playback = __addon__.getSetting('notif_during_playback')
self.notif_scrobbling = __addon__.getSetting('notif_scrobbling')
self.progress = __addon__.getSetting('progress')
self.http = __addon__.getSetting('http')
self.http_playing = False
self.emotion = __addon__.getSetting('emotion')
self.defaultemotion = __addon__.getSetting('defaultemotion')
if self.token is '':
log(__language__(32901))
if self.notifications == 'true':
notif(__language__(32901), time=2500)
return
self.user = self._GetUser()
if not self.user.is_authenticated:
return
self._monitor = Monitor(action = self._reset)
log('Player - monitor')
示例6: onPlayBackStopped
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def onPlayBackStopped(self):
self._playbackLock = False
url = "http://" + LOCAL_IP + ":" + str(VIDEO_PORT) + "/"
xbmc.sleep(300)
if os.path.exists("/proc/" + str(self.spsc_pid)) and xbmc.getCondVisibility(
"Window.IsActive(epg.xml)") and settings.getSetting('safe_stop') == "true":
if not xbmc.Player().isPlaying():
player = streamplayer(spsc_pid=self.spsc_pid, listitem=self.listitem)
player.play(url, self.listitem)
else:
try:
os.kill(self.spsc_pid, 9)
except:
pass
try:
xbmcvfs.delete(os.path.join(pastaperfil, 'sopcast.avi'))
except:
pass
示例7: update_info
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def update_info(self, force):
cur_playback = self.__sp.current_playback()
if cur_playback:
if cur_playback["is_playing"] and (not xbmc.getCondVisibility("Player.Paused") or force):
player_title = None
if self.isPlaying():
player_title = self.getMusicInfoTag().getTitle().decode("utf-8")
trackdetails = cur_playback["item"]
if trackdetails is not None and (not player_title or player_title != trackdetails["name"]):
log_msg("Next track requested by Spotify Connect player")
self.start_playback(trackdetails["id"])
elif cur_playback["is_playing"] and xbmc.getCondVisibility("Player.Paused"):
log_msg("Playback resumed from pause requested by Spotify Connect")
self.__skip_events = True
self.play()
elif not xbmc.getCondVisibility("Player.Paused"):
log_msg("Pause requested by Spotify Connect")
self.__skip_events = True
self.pause()
else:
self.__skip_events = True
self.stop()
示例8: play_connect
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def play_connect(self):
'''start local connect playback - called from webservice when local connect player starts playback'''
playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
trackdetails = None
count = 0
while not trackdetails and count < 10:
try:
cur_playback = self.sp.current_playback()
trackdetails = cur_playback["item"]
except:
count += 1
xbmc.sleep(500)
if not trackdetails:
log_msg("Could not retrieve trackdetails from api, connect playback aborted", xbmc.LOGERROR)
else:
url, li = parse_spotify_track(trackdetails, silenced=False, is_connect=True)
playlist.clear()
playlist.add(url, li)
playlist.add("http://localhost:%s/nexttrack" % PROXY_PORT)
player = xbmc.Player()
player.play(playlist)
del playlist
del player
示例9: play_playlist
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def play_playlist(self):
'''play entire playlist'''
if not self.local_playback:
self.connect_playback()
else:
playlistdetails = self.get_playlist_details(self.ownerid, self.playlistid)
kodi_playlist = xbmc.PlayList(0)
kodi_playlist.clear()
kodi_player = xbmc.Player()
# add first track and start playing
url, li = parse_spotify_track(playlistdetails["tracks"]["items"][0])
kodi_playlist.add(url, li)
kodi_player.play(kodi_playlist)
# add remaining tracks to the playlist while already playing
for track in playlistdetails["tracks"]["items"][1:]:
url, li = parse_spotify_track(track)
kodi_playlist.add(url, li)
示例10: direct_play
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def direct_play(url):
_log("direct_play ["+url+"]")
title = ""
try:
xlistitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", path=url)
except:
xlistitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", )
xlistitem.setInfo( "video", { "Title": title } )
playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
playlist.clear()
playlist.add( url, xlistitem )
player_type = xbmc.PLAYER_CORE_AUTO
xbmcPlayer = xbmc.Player( player_type )
xbmcPlayer.play(playlist)
示例11: onClick
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def onClick(self, controlID):
if (controlID == 2 or controlID == 22):
self.close()
if (controlID == 30):
self.close()
self.listitem = xbmcgui.ListItem(self.movieInfo['title'], iconImage=self.movieInfo['poster'], thumbnailImage=self.movieInfo['poster'])
if(self.quilitybutton.isSelected()):
xbmc.Player().play(self.movieInfo['direct_url_hq'], self.listitem)
else:
xbmc.Player().play(self.movieInfo['direct_url'], self.listitem)
if(controlID == 33):
__settings__ = xbmcaddon.Addon(id='plugin.video.watch.is.dev')
path = xbmc.translatePath(os.path.join(__settings__.getAddonInfo('path').replace(';', ''), ''))
w = DialogReviews("reviews.xml", path, "Default")
w.doModal(self.movieInfo['movieHtml'])
del w
示例12: build_selectbox
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def build_selectbox(self, clearsetting=False, assertplayers=True):
self.itemlist, self.actions = [], []
if clearsetting:
self.itemlist.append(xbmcgui.ListItem(xbmc.getLocalizedString(13403))) # Clear Default
if self.is_local:
self.append_playeraction(u'{0} {1}'.format(self.addon.getLocalizedString(32061), 'Kodi'), self.is_local, identifier='play_kodi')
for i in sorted(self.play_movie, key=lambda x: x[1]):
self.build_playeraction(i[0], 'play_movie', assertplayers=assertplayers)
for i in sorted(self.search_movie, key=lambda x: x[1]):
self.build_playeraction(i[0], 'search_movie', assertplayers=assertplayers)
for i in sorted(self.play_episode, key=lambda x: x[1]):
self.build_playeraction(i[0], 'play_episode', assertplayers=assertplayers)
for i in sorted(self.search_episode, key=lambda x: x[1]):
self.build_playeraction(i[0], 'search_episode', assertplayers=assertplayers)
utils.kodi_log(u'Player -- Built {} Players!\n{}'.format(
len(self.itemlist), self.identifierlist), 2)
示例13: onPlayBackStarted
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def onPlayBackStarted(self):
for f in self.on_playback_started:
f()
try: xbmc.Player().setSubtitles(self.subtitles)
except: pass
track_event("video", "play", self.display_name)
示例14: run
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def run(self):
import objects
''' Workaround for widgets only playback.
Widgets start with a music playlist, this causes bugs in skin, etc.
Create a new video playlist for the item and play it.
'''
xbmc.sleep(200) # Let Kodi catch up
LOG.info("-->[ widget play ]")
play = None
xbmc.PlayList(xbmc.PLAYLIST_MUSIC).clear()
xbmc.PlayList(xbmc.PLAYLIST_VIDEO).clear()
objects.utils.enable_busy_dialog()
try:
server = self.params.get('server')
if not server and not window('emby_online.bool'):
dialog("notification", heading="{emby}", message=_(33146), icon=xbmcgui.NOTIFICATION_ERROR)
raise Exception("NotConnected")
play = objects.PlayStrm(self.params, server)
play.play()
except Exception as error:
LOG.exception(error)
objects.utils.disable_busy_dialog()
xbmc.Player().stop() # mute failed playback pop up
xbmc.PlayList(xbmc.PLAYLIST_VIDEO).clear()
else:
objects.utils.disable_busy_dialog()
window('emby.play.widget.bool', True)
play.start_playback()
self.server.pending = []
LOG.info("--<[ widget play ]")
示例15: __init__
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import Player [as 别名]
def __init__(self, monitor=None):
self.monitor = monitor
xbmc.Player.__init__(self)