Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

8tracks: song info is now displayed properly in xbox and dharma versions

finally got subclassing of xbmc.Player to work properly!
  • Loading branch information...
commit 220424c5fce5c3706edc6059d42d95874183d564 1 parent 9f9c731
@t0mm0 authored
View
52 plugin.audio.8tracks/default.py
@@ -38,54 +38,14 @@
play = Addon.plugin_queries['play']
next = Addon.plugin_queries.get('next', None)
-if play or next:
- next_mix = False
+if play:
user = Addon.plugin_queries['user']
img = Addon.plugin_queries['img']
mix_name = Addon.plugin_queries['mix_name']
mix_id = play or next
- if play:
- result = et.play(mix_id)
- pl = Addon.get_playlist(xbmc.PLAYLIST_MUSIC, True)
- else:
- result = et.next(mix_id)
- pl = Addon.get_playlist(xbmc.PLAYLIST_MUSIC)
-
- if result['set']['at_end']:
- result = et.next_mix(mix_id)
- pl.remove(Addon.build_plugin_url({'next': mix_id,
- 'mix_name': mix_name,
- 'user': user,
- 'img': img}))
- next_mix = result['next_mix']
- mix_id = next_mix['id']
- mix_name = next_mix['name']
- user = next_mix['user']['login']
- img = next_mix['cover_urls']['max200']
- result = et.play(mix_id)
-
- if play or next_mix:
- Addon.add_music_item(Addon.build_plugin_url({'next': mix_id,
- 'mix_name': mix_name,
- 'user': user,
- 'img': img}),
- {'title': mix_name, 'artist': user},
- img=img, playlist=pl)
- t = result['set']['track']
- Addon.add_music_item(t['url'], {'title': t['name'],
- 'artist': t['performer'],
- 'album': t['release_name']}, img=img,
- playlist=pl, playlist_pos=-1)
-
- if play:
- xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(pl)
- else:
- listitem = xbmcgui.ListItem(t['name'], iconImage=img,
- thumbnailImage=img)
- listitem.setInfo('music', {'title': t['name'], 'artist': t['performer'],
- 'album': t['release_name']})
- Addon.resolve_url(t['url'], listitem)
-
+ player = EightTracksPlayer(xbmc.PLAYER_CORE_DVDPLAYER, et=et)
+ player.play_mix(mix_id, mix_name, user, img)
+
elif mode == 'mixes':
sort = Addon.plugin_queries.get('sort', '')
tag = Addon.plugin_queries.get('tag', '')
@@ -100,7 +60,7 @@
Addon.add_directory({'play': mix['id'], 'mix_name': mix['name'],
'img': mix['cover_urls']['max200'],
'user': mix['user']['login']},
- name, mix['cover_urls']['max200'])
+ name, mix['cover_urls']['max200'], folder=False)
if result['next_page']:
Addon.add_directory({'mode': 'mixes', 'sort': sort, 'tag': tag,
'search': search, 'page': result['next_page']},
@@ -135,7 +95,7 @@
Addon.add_directory({'mode': 'tags'}, Addon.get_string(30016))
Addon.add_directory({'mode': 'mixes', 'search': 1}, Addon.get_string(30017))
-if not (play or next):
+if not play:
Addon.end_of_directory()
View
5 plugin.audio.8tracks/resources/lib/Addon.py
@@ -103,7 +103,8 @@ def add_video_item(url, infolabels, img='', fanart='', total_items=0, playlist=F
xbmcplugin.addDirectoryItem(plugin_handle, url, listitem,
isFolder=False, totalItems=total_items)
-def add_directory(url_queries, title, img='', fanart='', total_items=0):
+def add_directory(url_queries, title, img='', fanart='', total_items=0,
+ folder=True):
url = build_plugin_url(url_queries)
log('adding dir: %s - %s' % (title, url))
listitem = xbmcgui.ListItem(decode(title), iconImage=img, thumbnailImage=img)
@@ -111,7 +112,7 @@ def add_directory(url_queries, title, img='', fanart='', total_items=0):
fanart = addon.getAddonInfo('path') + '/fanart.jpg'
listitem.setProperty('fanart_image', fanart)
xbmcplugin.addDirectoryItem(plugin_handle, url, listitem,
- isFolder=True, totalItems=total_items)
+ isFolder=folder, totalItems=total_items)
def add_artist(artist, total_items=0):
url_queries = {'mode': 'get_music_directory', 'id': artist['id']}
View
56 plugin.audio.8tracks/resources/lib/eighttracks.py
@@ -125,23 +125,55 @@ def _get_json(self, method, queries={}):
class EightTracksPlayer(xbmc.Player):
def __init__(self, *args, **kwargs):
xbmc.Player.__init__(self)
+ self.et = kwargs['et']
+ self.pl = Addon.get_playlist(xbmc.PLAYLIST_MUSIC, True)
+ self.ended = False
self.track_playing = False
- def play(self, item, listitem):
- self.track_playing = True
- xbmc.Player.play(self, item, listitem)
-
def onPlayBackStarted(self):
Addon.log('onPlayBackStarted')
- while self.track_playing:
- Addon.log('player sleeping...')
- xbmc.sleep(1000)
+ self.add_next()
- def onPlayBackEnded(self):
- Addon.log('onPlayBackEnded')
- self.track_playing = False
-
def onPlayBackStopped(self):
Addon.log('onPlayBackStopped')
- self.track_playing = False
+ self.ended = True
+
+ def play_mix(self, mix_id, mix_name, user, img):
+ Addon.log('play_mix')
+ self.mix_id = mix_id
+ self.mix_name = mix_name
+ self.user = user
+ self.img = img
+ self.add_next(True)
+ self.play(self.pl)
+ while not self.ended:
+ Addon.log('player sleeping...')
+ xbmc.sleep(1000)
+
+ def add_next(self, first=False):
+ Addon.log('add_next')
+ if first:
+ result = self.et.play(self.mix_id)
+ else:
+ result = self.et.next(self.mix_id)
+ if result['set']['at_end']:
+ Addon.log('moving to next mix')
+ result = self.et.next_mix(self.mix_id)
+ next_mix = result['next_mix']
+ self.mix_id = next_mix['id']
+ self.mix_name = next_mix['name']
+ self.user = next_mix['user']['login']
+ self.img = next_mix['cover_urls']['max200']
+ result = self.et.play(self.mix_id)
+
+ t = result['set']['track']
+ comment = 'mix: %s by %s' % (self.mix_name, self.user)
+ Addon.add_music_item(t['url'], {'title': t['name'],
+ 'artist': t['performer'],
+ 'comment': comment,
+ 'album': t['release_name']},
+ img=self.img, playlist=self.pl)
+ while not self.isPlaying() and not first and not self.ended:
+ Addon.log('player sleeping (add_next)...')
+ xbmc.sleep(1000)
Please sign in to comment.
Something went wrong with that request. Please try again.