Esempio n. 1
0
        private async void GetSoundCloudSessionStatus()
        {
            try
            {
                IsSoundCloudButtonEnabled = false;

                _soundCloudSessionStatus = await SoundCloudHelper.GetSessionStatusAsync();

                switch (_soundCloudSessionStatus)
                {
                case SoundCloudSessionStatus.Connected:
                    SoundCloudStatusText = AppResources.AccountConnectedStatusText;
                    break;

                case SoundCloudSessionStatus.NotConnected:
                    SoundCloudStatusText = AppResources.AccountDisconnectedStatusText;
                    break;

                case SoundCloudSessionStatus.Unknown:
                    SoundCloudStatusText = AppResources.AccountUnknownStatusText;
                    break;
                }
            }
            catch
            {
                SoundCloudStatusText = AppResources.AccountErrorStatusText;
            }
            finally
            {
                IsSoundCloudButtonEnabled = true;
            }
        }
Esempio n. 2
0
        private async Task <string> UploadToSoundCloudAsync()
        {
            _cts = new CancellationTokenSource();
            _cts.Token.Register(OnUploadCanceled);
            _scProgress = new Progress <SoundCloudUploadProgressChangedEventArgs>(OnSoundCloudUploadProgress);

            _cts.Token.ThrowIfCancellationRequested();

            var status = await SoundCloudHelper.GetSessionStatusAsync();

            if (status != SoundCloudSessionStatus.Connected)
            {
                throw new InvalidOperationException("Not connected.");
            }

            var link = await SoundCloudHelper.UploadFileAsync(_memo.Title, _memo.AudioFile, _memo.AudioFormat == "MP3"? "audio/x-mpeg" : "audio/x-wav", _cts.Token, _scProgress);

            return(link);
        }