Ejemplo n.º 1
0
        public void NextSong(bool isUserRequested)
        {
            if (!IsMixPresent)
            {
                return;
            }

            if (currentMix.GetCurrentTrack().IsLast)
            {
                NextMix();
                return;
            }

            if (currentMix.CurrentTrackIndex == currentMix.Tracks.Count - 1)
            {
                NextSongRequest  nextSongRequest = requestFactory.CreateNextSongRequest(playToken, currentMix.MixId, isUserRequested);
                PlaySongResponse playSongReponse = requestExecutor.ExecuteNextSongRequest(nextSongRequest);

                currentMix.AddTrack(new Track(playSongReponse.SetElement.TrackElement,
                                              playSongReponse.SetElement.AtLastTrack,
                                              playSongReponse.SetElement.SkipAllowed));
            }

            currentMix.MoveToNextTrack();

            if (audioPlayerProxy.Status == MediaStatus.Running)
            {
                PlayCurrentTrack(currentMix);
            }
        }
Ejemplo n.º 2
0
        public void Play(Mix mix)
        {
            if (playToken.Length == 0)
            {
                playToken = GetPlayToken();
            }

            if (mix.Tracks.Count == 0)
            {
                PlayMixRequest   playMixRequest  = requestFactory.CreatePlayMixRequest(playToken, mix.MixId);
                PlaySongResponse playSongReponse = requestExecutor.ExecutePlayMixRequest(playMixRequest);

                Track openingTrack = new Track(playSongReponse.SetElement.TrackElement,
                                               playSongReponse.SetElement.AtLastTrack,
                                               playSongReponse.SetElement.SkipAllowed);
                if (String.IsNullOrEmpty(openingTrack.Uri))
                {
                    return;
                }

                mix.AddTrack(openingTrack);
            }

            // in case we want to play the same mix again,
            // it means we don't change anything in the UI
            // just reset the counter and start again
            if (currentMix == null || !mix.RestfulUri.Equals(currentMix.RestfulUri))
            {
                currentMix = mix;
                currentMixObservable.OnNext(currentMix);
            }

            currentMix.ResetTrackIndex();
            PlayCurrentTrack(currentMix);
        }