Exemplo n.º 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() }
            });
        }
    }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public string GetLink()
        {
            IList <string> soundIds   = _player.GetActiveIds();
            var            encodedIds = new string[soundIds.Count];

            for (int i = 0; i < soundIds.Count; i++)
            {
                encodedIds[i] = GuidEncoder.Encode(soundIds[i]);
            }
            return($"https://ambie-app.azurewebsites.net/play?sounds={string.Join(",", encodedIds)}");
        }