Play Stream and switch to “Now Playing”

Hallo,

it’s my first plugin I what to write for my Rasperry Pi using Kodi. The idea is simple. Just want a music addon that plays a stream direct after opening and switch in remote app to the “Now Playing” screen. I tried different ways using xbmc.Player and xbmcplugin.setResolvedUrl . But in both ways the switch to the “Now Playing” Screen doesen’t work.

PHP Code:
def stream_url(url):
    
play_item xbmcgui.ListItem(path=url)
    
xbmcplugin.setResolvedUrl(addon_handleTruelistitem=play_item)

url 'https://detektor.fm/stream/mp3/wort/'
stream_url(url

PHP Code:
def playNow(url):
    
li xbmcgui.ListItem('titel''description'addonpath "/resources/media/foo.png")
    
li.setInfo('music', {'Title''test',
       
'Artist''foo'})
    
li.setProperty('mimetype''audio/mpeg')
    
li.setProperty('IsPlayable''true')
    
li.setInfo('music', {
       
'Title''baa'
    
})
    
Player().play(item=urllistitem=li)

url 'https://detektor.fm/stream/mp3/wort/'
playNow(url

Any Idea?