Jump to content

Web client ignoring AudioStreamIndex and SubtitleStreamIndex


Recommended Posts

Posted

IWhen receiving a remote control PlayCommand (ISessionManager.SendPlayCommand) of type PlayNow for a video, the web client seems to discard the AudioStreamIndex and SubtitleStreamIndex sent with the PlayRequest instead of using them in the requested video(s). Instead, I think the web client uses the default or preset audio and subtitle tracks.

This isn't super urgent for me since I already fixed it in the client patch I'm maintaining for myself, but I figured I might as well report it so it can be fixed in the future.

I think even if a playback queue with multiple items is provided, if an AudioStreamIndex or SubtitleStreamIndex are provided, they should be used in the first video.

modules/common/playback/playbackmanager.js

function playAfterBitrateDetect(maxBitrate, item, playOptions, onPlaybackStartedFn, signal) {

    ...
    
    Object.assign(streamInfo, createStreamInfo(apiClient, item.MediaType, item, mediaSource, mediaSourceInfo.playSessionId, startPosition)),
    getPlayerData(player).maxStreamingBitrate = maxBitrate,
    onPlaybackStartedFn(),
    player.play(streamInfo, signal).then(...)
    
    ...
    
}

HtmlVideoPlayer.play only receives a streamInfo, but createStreamInfo doesn't have access to playOptions and cannot make use of AudioStreamIndex and SubtitleStreamIndex.

A quick fix that doesn't require changes to HtmlVideoPlayer does something like:

    if (typeof playOptions.audioStreamIndex == "number") streamInfo.mediaSource.DefaultAudioStreamIndex = playOptions.audioStreamIndex;
    if (typeof playOptions.subtitleStreamIndex == "number") streamInfo.mediaSource.DefaultSubtitleStreamIndex = playOptions.subtitleStreamIndex;

 

Posted

Hi, I tested this by using one instance of the web app to remote control another and it worked just fine.

Posted

There's definitely a code path that uses the audioStreamIndex and subtitleStreamIndex, but I assure you the one I pointed out above, which sends the streamInfo directly to the player and does not make use of audioStreamIndex and subtitleStreamIndex, is the one my client is using when receiving the PlayCommand from my plugin.

You're better equipped than I am to know when the client uses that code path, as I don't have access to legible source code.

If I use the patch above to copy the playOptions stream indices to the MediaSource defaults, the streams will be correctly set, so the contents of playOptions must be correct.

    PlayRequest request = new PlayRequest();
    request.ItemIds = party.CurrentQueue;  //long[] Ids from SessionInfo.NowPlayingQueue
    request.StartIndex = party.CurrentIndex;  //int
    request.StartPositionTicks = host.PositionTicks;  //long
    request.PlayCommand = playCommand;  //Always PlayCommand.PlayNow
    request.AudioStreamIndex = party.AudioStreamIndex;  //Someone else's PlaySession.PlayState.AudioStreamIndex
    request.SubtitleStreamIndex = party.SubtitleStreamIndex;  //Someone else's PlaySession.PlayState.SubtitleStreamIndex
    ...
    _sessionManager.SendPlayCommand(null, attendee.Id, request, new System.Threading.CancellationToken());

 

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...