예제 #1
0
        /// <inheritdoc/>
        public async void Process(Uri uri)
        {
            if (uri?.Query == null)
            {
                return;
            }

            var queryString = HttpUtility.ParseQueryString(uri.Query);
            var sounds      = queryString["sounds"] ?? "";

            if (string.IsNullOrWhiteSpace(sounds))
            {
                return;
            }
            string[] list = sounds.Split(',');

            for (int x = 0; x < list.Length; x++)
            {
                list[x] = GuidEncoder.Decode(list[x]).ToString();
            }

            Sound tempSoundMix = new()
            {
                SoundIds = list,
                IsMix    = true
            };

            var allLoaded = await _soundMixService.LoadMixAsync(tempSoundMix);

            bool manuallyPlayed = false;
            int  tracksplayed   = list.Length;

            if (!allLoaded)
            {
                // show the share result to the user and let them download missing sounds.
                IList <string> soundIdsToPlay = await _dialogService.OpenShareResultsAsync(list);

                if (soundIdsToPlay != null && soundIdsToPlay.Count > 0)
                {
                    manuallyPlayed        = true;
                    tempSoundMix.SoundIds = soundIdsToPlay.ToArray();
                    await _soundMixService.LoadMixAsync(tempSoundMix);
                }

                tracksplayed = soundIdsToPlay != null ? soundIdsToPlay.Count : 0;
            }

            _telemetry.TrackEvent(TelemetryConstants.ShareReceived, new Dictionary <string, string>()
            {
                { "auto played", allLoaded.ToString() },
                { "manually played", manuallyPlayed.ToString() },
                { "tracks played count", tracksplayed.ToString() }
            });
        }
    }
예제 #2
0
 /// <summary>
 /// Loads this sound into the player and plays it.
 /// </summary>
 public async void Play()
 {
     if (!_sound.IsMix)
     {
         await _playerService.ToggleSoundAsync(_sound);
     }
     else
     {
         await _soundMixService.LoadMixAsync(_sound);
     }
 }