Hi, thank you for helping. Code is simple but waitForAbort method do the same. Maybe threading would be solution?
python:
# -*- coding: utf-8 -*-
import xbmc
import xbmcgui
import xbmcplugin
import xbmcaddon
import requests
import os
import threading
class It(xbmcgui.ListItem):
def __init__(self):
xbmcgui.ListItem.__init__(self)
def update_info(self):
icon=os.path.join(xbmcaddon.Addon().getAddonInfo('path'),'icon.png')
artist,song,fanart=get_info()
self.setArt({"thumb":icon, "fanart":fanart, "icon":icon})
self.setInfo("music", {"title": song, "artist": artist})
class RadioBeat(xbmc.Player):
def __init__(self):
xbmc.Player.__init__(self)
def PlayRadio(self):
stream="http://icecast2.play.cz/radiobeat128.mp3"
it=It()
it.setPath(stream)
it.update_info()
self.play(item=stream, listitem=it)
xbmc.Monitor().waitForAbort(4)
def InfoDaemon(self):
while self.isPlayingAudio():
it=It()
it.update_info()
it.setPath(xbmc.Player().getPlayingFile())
self.updateInfoTag(it)
xbmc.Monitor().waitForAbort(4)
def get_info():
url="http://onair.play.cz/json/beat.json"
r=requests.get(url)
info=r.json()
artist=info["artist"].title().encode('utf-8')
song=info["song"].title().encode('utf-8')
fanart=info["img"]
return artist,song,fanart
xbmc.executebuiltin("ActivateWindow(12006)")
radio=RadioBeat()
radio.PlayRadio()
radio.InfoDaemon()