NEWBIE - Playing audio content on iOS devices

plugin-dev

#1

Hello Gurus,

I'm not much of a coder but I can follow the logic of code decently and I'm fairly ok at troubleshooting issues. I've been trying to update some channels that seem to be abandoned to work with the iOS player. I keep receiving the "Unable to start a playback session" error. Could someone please post a working example of the CreateTrackObject or point me to a post? I've searched the forums but could have missed it. That way I can start with something that works and then I can fool with breaking it. Any help will be greatly appreciated!

Here's what I'm working with on the PlexPod plugin. I already can follow that the url, title, thumb, and summary seem to be correctly associated earlier in the code.

`def CreateTrackObject(url, title, thumb, summary, include_container=False):

if url.endswith('.mp3'):
    container = 'mp3'
    audio_codec = AudioCodec.MP3
else:
    container = Container.MP4
    audio_codec = AudioCodec.AAC

track_object = TrackObject(
    key = Callback(CreateTrackObject, url=url, title=title, thumb=thumb, summary=summary, include_container=True),
    rating_key = url,
    title = title,
    thumb = thumb,
    summary = summary,
    duration = 10000,
    items = [
        MediaObject(
            parts = [
                PartObject(key=url)
            ],
            container = container,
            audio_codec = audio_codec,
            audio_channels = 2
        )
    ]
)

if include_container:
    return ObjectContainer(objects=[track_object])
else:
    return track_object`

#2

Go to the Services bundle on Github (github.com/plexinc-plugins/Services.bundle). From that you can, search that repository for any key words and find a lot of code for playing media.

Most channels have a separate URL service to handle playback.

See Channel Plugin Development Support Documents. The "Introduction to URL Services" link explains when you would need to use a separate URL service and gives examples of playback code in a plugin vs using a separate URL service.


#3

@shopgirl284 - Thanks! I'll take look and see if I can figure this out.


#4

Also here is an example of a CreateAudioObject function if it helps - github.com/shopgirl284/RSSFeed.bundle/blob/master/Contents/Code/mediaobjects.py#L7


#5

def CreateTrackObject(url, title, thumb, include_container=False, includeBandwidths=0)
make sure you have the includeBandwidths parameter, this one is required for ios


#6

@shopgirl284 and @d3v1 - Thank you for answering me! I haven't been able to do much coding this past month or so. Life got hard quickly. Going to start up in a week or two. I'll check out both.


#7

Just to report back, adding the includeBandwidths=0 worked like a charm. Now on to fixing several iOS channels!