SheaSmith / atv.js

A JavaScript framework designed to simplify and accelerate the development of apps for the Apple TV 3
0 stars 0 forks source link

Event groups cannot be added to the video player in XML #3

Closed SheaSmith closed 2 years ago

SheaSmith commented 2 years ago

Event groups cannot be added to httpLiveStreamingVideoAsset in the XML layout. When attempting to do as specified by the XSD, as follows:

<eventGroup>https://app-url/eventgroup.xml</eventGroup>

The Apple TV returns a validation error, saying that it expects a title (e.g. it expects the normal eventGroup tag that would normally be present in the body). This is despite the XSD having the following rule:

<xs:element name="eventGroup" type="eventGroupURLType" minOccurs="0" maxOccurs="unbounded"/>

However, when complying with the validation rules (and not the XSD), the event group is not loaded (it doesn't display on the transport controls, nor does it appear when querying atv.player.eventGroups).

SheaSmith commented 2 years ago

Additionally, it appears you cannot manually add event groups via pushing to the array atv.player.eventGroups.

SheaSmith commented 2 years ago

Looks like I misunderstood the way the httpLiveStreamingVideoAsset is defined in the XSD:

<xs:element name="httpLiveStreamingVideoAsset">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="mediaURL"/>
                <xs:element ref="title" minOccurs="0"/>
                <xs:element ref="description" minOccurs="0"/>
                <xs:element name="image" type="imageType" minOccurs="0"/>
                <xs:element name="bookmarkTime" type="timeIntervalSecondsType" minOccurs="0"/>
                <xs:element ref="trickPlayConfig" minOccurs="0"/>
                <xs:element name="eventGroup" type="eventGroupURLType" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="secondScreenURL" minOccurs="0" maxOccurs="1"/>
                <xs:element ref="subtitleStylesURL" minOccurs="0" maxOccurs="1"/>
                <xs:element name="bookmarkNetTime" type="timeIntervalSecondsType" minOccurs="0"/>
                <xs:element name="startDate" type="startDateType" minOccurs="0"/>
                <xs:element ref="rating" minOccurs="0"/>
                <xs:element name="ratingValue" type="xs:nonNegativeInteger" minOccurs="0"/>
                <xs:element name="ratingSystem" type="xs:string" minOccurs="0"/>
                <xs:element name="upNextPresentationTime" type="timeIntervalSecondsType" minOccurs="0"/>
                <xs:element name="upNextPresentationDuration" type="timeIntervalSecondsType" minOccurs="0"/>
                <xs:element name="fpsKeyServerURL" type="xs:anyURI" minOccurs="0"/>
                <xs:element name="fpsCertificateURL" type="xs:anyURI" minOccurs="0"/>
                <xs:element ref="fpsKeyServerParameters" minOccurs="0" maxOccurs="1"/>
                <xs:element name="tokenServerURL" type="xs:anyURI" minOccurs="0"/>
                <xs:element name="stopURL" type="xs:anyURI" minOccurs="0"/>
                <xs:element ref="tokenServerParameters" minOccurs="0" maxOccurs="1"/>
                <xs:element name="channelName" type="xs:string" minOccurs="0"/>
                <xs:element name="channelID" type="xs:string" minOccurs="0"/>
                <xs:element name="externalAssetID" type="xs:string" minOccurs="0"/>
                <xs:element ref="floatingButtons" minOccurs="0"/>
                <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute ref="id" use="optional"/>
            <xs:attribute name="indefiniteDuration" type="xs:boolean" use="optional"/>
            <xs:attribute ref="cachingIdentifierBehavior" use="optional"/>
        </xs:complexType>
    </xs:element>

Basically the important parts are the xs:sequence bit, which essentially means the tags have to be in that order. However, as the final entry in the sequence is the following;

<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>

it basically results in most elements working fine regardless of the order. However, as eventGroup is defined elsewhere, the player will attempt to parse it as if it is a child of the body element, rather than as a child of the httpLiveStreamingVideoAsset element. If you use the eventGroup tag in the correct order, it will parse correctly and you will get the event groups being successfully retrieved from the external file.