Question regarding channel playback

Hi, I have a question regarding how to create playback items for channel. I’ve follow through the “development Walkthrough” post and got an idea how to extract various video lists and structures from website using XPATH. I’ve been trying to understand how the actual media player object can be added.

As a test I found a url for a certain MP4 files online. When opening the .mp4 URL in chrome it’ll directly download the mp4 files. So I suppose this is the file stream that can be used for media playback. I gather from the framework documentation that I need to add a VideoClipObject, so I try the following, but the player would say there’s error playing this item. I tried to reference other plugins code, and a lot of them seems to be using URLService, but some also manage to use an all-in-init solution… Is the URLService required? Also I’m very puzzled, as to what needs to be returned to Plex for playback to work? Is working with the .mp4 file the correct approach? The .mp4 is extracted from the flash player from the website, but I don’t see the stream.moe as one of the URLservice in the bundle…

Any help is much appreciated. Thanks!

@route(PREFIX + '/testplay')
def testplay():
    oc = ObjectContainer()
    testmediaurl = "https://redwolf.stream.moe/files/4/362nmxrs7pweui/Sakamoto Desu ka - 07 (720p, Subbed).mp4"
    oc.add(CreateVideo(testmediaurl))
    return oc

@route(PREFIX + '/watch')
def CreateVideo(url):
    video_object = VideoClipObject(
        key = Callback(CreateVideo, url=url),
        rating_key = "MasterAnimeBETA",
        items = [
            MediaObject(
                parts = [PartObject(key=url)],
                optimized_for_streaming = True,
                container = Container.MP4,
                audio_channels = 2
                )
            ]
        )
    return video_object

You have to create a media object xml document that includes a direct URL to the media stream. Each Plex player will use that document to determine how to play the media.

You can either create a separate URL service (see Services.bundle) or create a function in your plugin (See HGTV channel).

Here is a draft of a document that I am writing that may better explain the process and when it is best to create a separate URL service - docs.google.com/document/d/1ePST3Dk0KywSmmDu3OPqpiNilpVgZDSzPgB0ns1yiFU (Just be aware that it is still a draft)

You can use http://localhost:32400/channels/all to see all the XML returned by channels. Then from that list, http://localhost:32400 plus the key value to see the various directories within a specific channel. You can also add the token if you are using HOME and add X-Plex-Platform= to see what is returned for a specific Plex player app.(But remember if the key value includes a ? then you have to change these extensions to &)

For example, if you have installed the HGTV channel on your Plex Media Server, then localhost:32400/video/hgtv/videobrowse?url=http%3A%2F%2Fhgtv.com%2Fshows%2Fbrother-vs-brother%2Fbrother-vs-brother-full-episodes-videos&title=Brother+Vs.+Brother will show you the Media objects and parts for all of the HGTV videos for Brother vs Brother. Then to see the media object details for any video listed, put the key value for a part after http://localhost:32400

The media object xml returned for the first video in that list -
<MediaContainer title1="HGTV" art="http://resources-cdn.plexapp.com/image/art/com.plexapp.plugins.hgtv.jpg?h=0720efe" size="1" identifier="com.plexapp.plugins.hgtv" sourceTitle="HGTV" mediaTagPrefix="/system/bundle/media/flags/"> <Video thumb="http://resources-cdn.plexapp.com/image/source/com.plexapp.plugins.hgtv.jpg?h=966fa74" sourceIcon="http://resources-cdn.plexapp.com/image/source/com.plexapp.plugins.hgtv.jpg?h=966fa74" key="http://sniidevices.scrippsnetworks.com/0236/0236755_6.mp4" type="clip"> <Media audioChannels="2" height="720" width="1280" container="mp4" audioCodec="aac" videoCodec="h264" videoResolution="720"> <Part container="mp4" key="http://sniidevices.scrippsnetworks.com/0236/0236755_6.mp4" file=""> <Stream index="0" selected="1" streamType="1" height="720" width="1280" codec="h264" id="1"/> <Stream index="1" selected="1" streamType="2" channels="2" codec="aac" id="2"/> </Part> </Media> </Video> </MediaContainer>

For the XML for a media object returned by a URL service you just use http://localhost:32400/system/services/url/lookup?url=insert encoded URL here Then again add the key value for any part to http://localhost:32400 to see the media object XML the player will read.

And one of the guys wrote a great Chrome addon-on called Plex Media Server XML Helper that makes it easier to read the xml files in Chrome.

Also see forums.plex.tv/discussion/comment/476392/#Comment_476392