コード例 #1
0
        public async Task <string> Load([NotNull] JObject obj)
        {
            var k = (PlayCommandHelper.GetPlayOrigin(obj) as JObject);

            ConnectState.PlayOrigin = ProtoUtils.JsonToPlayOrigin(k !);
            ConnectState.Options    =
                ProtoUtils.JsonToPlayerOptions((JObject)PlayCommandHelper.GetPlayerOptionsOverride(obj), ConnectState.Options);
            var sessionId = SetContext(ProtoUtils.JsonToContext((JObject)PlayCommandHelper.GetContext(obj)));

            var trackUid   = PlayCommandHelper.GetSkipToUid(obj);
            var trackUri   = PlayCommandHelper.GetSkipToUri(obj);
            var trackIndex = PlayCommandHelper.GetSkipToIndex(obj);

            if (trackUri != null)
            {
                TracksKeeper.InitializeFrom(list => list.FindIndex(z => z.Uri == trackUri), null, null);
            }
            else if (trackUid != null)
            {
                TracksKeeper.InitializeFrom(list => list.FindIndex(z => z.Uid == trackUid), null, null);
            }
            else if (trackIndex != null)
            {
                TracksKeeper.InitializeFrom(list =>
                {
                    if (trackIndex < list.Count)
                    {
                        return((int)trackIndex);
                    }
                    return(-1);
                }, null, null);
            }
            else
            {
                TracksKeeper.InitializeStart();
            }

            var seekTo = PlayCommandHelper.GetSeekTo(obj);

            if (seekTo != null)
            {
                SetPosition((long)seekTo);
            }
            else
            {
                SetPosition(0);
            }
            await LoadTransforming();

            return(sessionId);
        }