Media¶
Under xenia-edge, media plays once the console's codec modules are installed. Everything around the player works:
MediaTransport, its transport bar and its commands.
- WMA plays as is: its decoder is built into the runtime.
- WMV, MP3 and MP4 need the console's extra AV codecs. The runtime gets their decoders from
dash.ExtraAVCodecs.xex, a module of the console's system software that it loads through xam (XamLoadExtraAVCodecs). Without it, playback fails withMediaFailed"4001 An error has occured" right afterOpening. Despite that code's name (AG_E_NETWORK_ERROR), the network isn't involved: the real error isC00DF804for WMV (no video decoder) and8007000Efor MP3. Under xenia-edge, copydash.ExtraAVCodecs.xexanddash.ExtraAVCodecs2.xexfrom your console's system files to thesysext\folder of xenia's storage root (next tocontent\). WMV (VC-1) and MP3 then play.- MP4 (H.264/AAC) also needs the console's Optional Media Update, a content package (machine-wide content of type 2 for title FFFE07DF) that isn't part of the system update. Without it, the runtime shows the "media update required" screen when playback starts, and that can't complete without Xbox LIVE. Install it by copying the package file to xenia's
content\0000000000000000\FFFE07DF\00000002\. With both, MP4 plays, but the picture is wrong: green blocks over the right base colour, because xenia doesn't support a texture format (k_32) the H.264 output uses. The first MP4 playback also waits for xenia to compile some very large shaders.To test without a server, put media files in
samples\apps\MediaPlayer\Mediaand rebuild; the sample lists them as "(in the package)" and plays them from a URI relative to the XAP.The rest of this page is from the platform's code and the shipped apps.
MediaElement¶
The standard Silverlight MediaElement, playing WMV, WMA, MP4 (H.264/AAC) and MP3 over progressive download, plus Smooth Streaming through SmoothStreamingMediaElement. The Xbox version adds DRM and output-protection members (see the reference).
It plays only from a URI. SetSource(Stream) throws NotImplementedException from the runtime's native side, so a file the app reads itself (from a drive, say) can't be handed to the player as a stream. Serve it over HTTP from the app instead, on a socket of its own, and point Source at that URL. The URL can be http://127.0.0.1:port/..., or the console's own address where loopback isn't reached. Serve byte ranges so the player can seek. A BitmapImage loads from a URI the same way.
MediaTransport¶
MediaTransport (Microsoft.Xbox.Controls) is the playback chrome every video app uses. It provides:
- the transport bar (play/pause, skip, rewind, fast forward, stop, info, display mode),
- the timeline, status text and busy indicator,
- controller and remote handling.
Put the player inside it:
<xbox:MediaTransport x:Name="Transport" Back="Transport_Back">
<MediaElement x:Name="Player" AutoPlay="True" />
</xbox:MediaTransport>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Transport.MediaAssetId = "episode-42"; // required, see below
Player.Source = new Uri(url, UriKind.Absolute);
Dispatcher.BeginInvoke(delegate { Transport.Focus(); });
}
private void Transport_Back(object sender, EventArgs e)
{
NavigationService.GoBack();
}
What it handles itself:
- Controller: A, Start or the D-pad shows the transport bar. The triggers rewind and fast forward. The shoulder buttons skip between chapter markers. B hides whatever is showing and raises
Backwhen nothing is left. - Remote commands: they go through
ExecuteMediaCommand. - Fast forward and rewind: they're emulated. The player pauses and the timeline previews ahead, then seeks when you resume.
Required: set MediaAssetId before any command. Each command is reported with it (for SmartGlass and usage statistics) and throws InvalidOperationException without it.
Side effects while it's loaded:
- Media app status: it tells the console a video is playing, so the dashboard treats the app as a media app.
- SmartGlass: it reports position and state for companion devices on every command and state change.
- Screen saver: it suppresses the screen saver during playback. This needs GamerServices, so use it inside
XboxApplicationFrame.
samples\apps\MediaPlayer plays files from the test server's media folder.
Smooth Streaming¶
SmoothStreamingMediaElement (Microsoft.Web.Media.SmoothStreaming) plays adaptive streams:
- Source: set
SmoothStreamingSourceto a.../ManifestURL. SettingSource(progressive) throwsNotSupportedExceptionon Xbox. - Set first: set
SmoothStreamingPlaybackMode,SmoothStreamingCache,CookieContainerandLivePlaybackStartPositionbefore the source. - Events:
ManifestReadycomes beforeMediaOpened. Restrict tracks withStreamInfo.RestrictTracksonly inManifestReady;SelectTracksworks at any time. - Errors: after
SmoothStreamingErrorOccurredthe source is shut down; set it again to retry. - Trick play:
SetPlaybackRateonly takes the values inSupportedPlaybackRates.
Wrap it for MediaTransport with SmoothStreamingMediaElementAdapter.
DRM¶
PlayReady-protected content goes through LicenseAcquirer and MediaElement.LicenseAcquirer, as in Silverlight. VideoOutputConnector.EngageHdcpAsync and EngageCgmsaAsync turn on output protection before protected playback. None of this has been tested.