I’m working on a new channel and trying to get streaming of audio tracks to work. I have a URL service all set up and the clients see the lists of tracks and so on just fine. The web client can also play the track just fine but other clients seem to have problems.
Android just seems to keep re-requesting the track stream and never plays anything.
Xbox One starts playing the track but shows up an error message saying that something has gone wrong.
My Vizio smart TV displays a red warning that the media server is not responding then skips to the next track.
My code is pretty straightforward, here is a snippet from the url service:
def MediaObjectsForTrack(library, track):
return [
MediaObject(
bitrate=320,
container=Container.MP3,
audio_codec=AudioCodec.MP3,
duration=track.duration,
parts=[PartObject(
key=Callback(
LibraryTrackStream,
libraryId=library.id,
trackId=track.id,
quality="hi"
),
duration=track.duration,
streams=[
AudioStreamObject(
selected=1,
bitrate=320,
codec=AudioCodec.MP3,
duration=track.duration
)
]
)]
)
]
def LibraryTrackStream(libraryId, trackId, quality, **kwargs):
library = music.get_library(libraryId)
client = library.get_stream_client()
url = client.get_stream_url(trackId, None, quality)
client.logout()
return Redirect(url)
I suspect I may need to use IndirectResponse instead of redirect but I can’t get that to work with any clients. Does anyone have any suggestions?
Also right now the client gets the actual url of the stream to play, I’d prefer having the media server act as a middle-man there and maybe transcode it so the server doesn’t see multiple IP addresses accessing the media at the same time.
Routes wouldn’t work in the URL Services though, you’d have to move the function to the Code section.