Having problem with playing video

I am currently developing a channel plugin and having an issue with playing video.

 

In my case, I am getting the following JSON response from the server when I load season specific data.

{
 "id": "1",
 "name": "abc",
 "poster_small": "http://hostname/image.jpg",
 "description": "ABC Description",
 "playlist": [
  {
     "name": "episode 1",
     "link:": "http://hostname/episode-1-DivX.mp4"
  }
 ]
}

To display video I am using the following code...

@route(PREFIX + "/watch_season")
def WatchSeason(id):
    # setup the search request url
    values = {'key': API_KEY, 'command': 'getSeason', 'season_id': id}
request = HTTP.Request(API_URL, values=values, cacheTime=CACHE_1DAY)
response = json.loads(request.content)

oc = ObjectContainer()
playlist = response.get('playlist')
for video in playlist:
    video_name = video.get('name')
    video_link = video.get('link')
    oc.add(
        VideoClipObject(
            url=video_link,
            title=video_name,
            summary=response.get('description'),
            thumb=response.get('poster_small'),
            items=[
                MediaObject(
                    optimized_for_streaming=True,
                    audio_codec=AudioCodec.AAC,
                    video_codec=VideoCodec.H264,
                    container=Container.MP4,
                    parts=[PartObject(key=Callback(PlayVideoIndirect, url=video_link))]
                )
            ]
        )
    )
return oc

@indirect
def PlayVideoIndirect(url):
return IndirectResponse(VideoClipObject, key=url)

Any ideas how I can play the video?

PS. I tried to set video_codec='divx' - doesn't work.

 

If you set the url parameter on a VideoClipObject, Plex Media Server expects that you use a URL Service. If you want to create a list with videos like you do from, for example, API output you have to set the rating_key and the key parameter, where rating_key is a unique value for the video (usually the video or webpage url is used for this) and key is a Callback to a function that also creates a VideoClipObject.

This sounds a bit strange and/or difficult maybe, so I hope an example makes it more clear: https://github.com/plexinc-plugins/Tagesschau.bundle/blob/master/Contents/Code/__init__.py#L21

Thank you, working fine B)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.