Exemple #1
0
        public void When_GetAudio_is_called_with_a_new_Audio_and_an_empty_string_for_setName_then_UploadAudio_on_the_AudioAdapter_is_called_with_that_Audio_and_the_stored_AudioAdapterSettings()
        {
            var tracks = AudioTrackCreator.CreateCollection();
            var entity = AdapterSettingsCreator.CreateSingle();

            entity.SetName = string.Empty;

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            AudioAdapter
            .Expect(adapter =>
                    adapter.GetItems(entity.SetName, entity.OAuthAccessToken))
            .Return(tracks)
            .Repeat.Once();
            AudioAdapter.Replay();

            var result = Process.GetAudioTracks();

            Assert.AreEqual(tracks.Count(), result.Count());
            Assert.AreEqual(tracks.First().ResourceUri, result.First().ResourceUri);

            AudioAdapter.VerifyAllExpectations();
        }
Exemple #2
0
        public void When_GetAudio_is_called_and_no_OAuthAccessToken_has_been_stored_then_an_InvalidOperationException_is_thrown_and_GetAudio_on_the_AudioAdapter_is_never_called()
        {
            var photoAdapterSettings = AdapterSettingsCreator.CreateSingle();

            photoAdapterSettings.OAuthAccessToken = null;

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(photoAdapterSettings)
            .Repeat.Once();
            BandRepository.Replay();

            AudioAdapter
            .Expect(adapter =>
                    adapter.GetItems(null, null))
            .IgnoreArguments()
            .Return(new List <AudioTrack>())
            .Repeat.Never();
            AudioAdapter.Replay();

            Process.GetAudioTracks(0, 10);

            AudioAdapter.VerifyAllExpectations();
        }
Exemple #3
0
        public void When_AddAudio_is_called_and_no_OAuthAccessToken_has_been_stored_then_an_InvalidOperationException_is_thrown_and_UploadAudio_on_the_AudioAdapter_is_never_called()
        {
            var          photo    = new MemoryStream();
            const string fileName = "photo.jpg";
            var          entity   = AdapterSettingsCreator.CreateSingle();

            entity.OAuthAccessToken = null;

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            AudioAdapter
            .Expect(adapter =>
                    adapter.UploadItem(null, null, null, null))
            .IgnoreArguments()
            .Return("")
            .Repeat.Never();
            AudioAdapter.Replay();

            Process.AddAudio(photo, fileName);

            AudioAdapter.VerifyAllExpectations();
        }
Exemple #4
0
        public void When_AddAudio_is_called_with_a_new_Audio_then_UploadAudio_on_the_AudioAdapter_is_called_with_that_Audio_and_the_stored_AudioAdapterSettings()
        {
            var          photo    = new MemoryStream();
            const string fileName = "photo.jpg";
            const string photoId  = "http://www.photos.com/myphoto";
            var          entity   = AdapterSettingsCreator.CreateSingle();

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            AudioAdapter
            .Expect(adapter =>
                    adapter.UploadItem(photo, entity.SetName, fileName, entity.OAuthAccessToken))
            .Return(photoId)
            .Repeat.Once();
            AudioAdapter.Replay();

            var result = Process.AddAudio(photo, fileName);

            Assert.AreEqual(photoId, result);

            AudioAdapter.VerifyAllExpectations();
        }
        public void PlayBadMp3()
        {
            IAudioPlayer player = new AudioAdapter();

            player.Play("mp3", "pianoooo");
            player.Resume();
            player.Pause();
            player.Dispose();
        }
        public void PlayBadWav()
        {
            IAudioPlayer player = new AudioAdapter();

            player.Play("wav", "BirabutoKing");
            player.Resume();
            player.Pause();
            player.Dispose();
        }
Exemple #7
0
        public AudioTrack GetAudioTrack(int id)
        {
            var adapterSettings = GetAdapterSettings();

            if (adapterSettings.OAuthAccessToken == null)
            {
                throw new AuthorizationException();
            }

            return(AudioAdapter.GetItem(id, adapterSettings.OAuthAccessToken));
        }
Exemple #8
0
        public IEnumerable <AudioTrack> GetAudioTracks(int page, int pageSize)
        {
            var adapterSettings = GetAdapterSettings();

            if (adapterSettings.OAuthAccessToken == null)
            {
                throw new AuthorizationException();
            }

            return(AudioAdapter.GetItems(adapterSettings.SetName, adapterSettings.OAuthAccessToken, page, pageSize));
        }
Exemple #9
0
        public void Authorize(Uri verificationUri)
        {
            if (verificationUri == null)
            {
                throw new ArgumentNullException("verificationUri");
            }

            var entity = GetAdapterSettings();

            var accessToken = AudioAdapter.GetOAuthAccessToken(verificationUri);

            entity.OAuthRequestToken = null;
            entity.OAuthAccessToken  = accessToken;
            UpdateAdapterSettings(entity);
        }
Exemple #10
0
        public string AddAudio(Stream audio, string fileName)
        {
            if (audio == null)
            {
                throw new ArgumentNullException("audio");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            var adapterSettings = BandRepository.GetAdapterSettings(AdapterName);

            if (adapterSettings.OAuthAccessToken == null)
            {
                throw new AuthorizationException();
            }

            return(AudioAdapter.UploadItem(audio, adapterSettings.SetName, fileName, adapterSettings.OAuthAccessToken));
        }
        private void audioCursor()
        {
            for (int i = 0; i < MySongs.Length; i++)
            {
                SongInfo cs         = MySongs[i];
                var      audioTitle = cs.title;
                var      artist     = cs.author;
                //var time = 0;
                //string timestring = convertDuration(Convert.ToInt32(time));
                var    arrPath     = cs.id.ToString();
                var    artistAlbum = "";
                String urlAlbum    = urlAlbumArt(artistAlbum);
                var    category    = manager.getSongCategory(arrPath);
                items.Add(new Datos()
                {
                    Title       = audioTitle, Artist = artist, ArrPath = arrPath,
                    ArtistAlbum = urlAlbum, Category = category
                });
            }

            listData.Adapter = audioAdapter = new AudioAdapter(this, items);
            setSongs();
        }
Exemple #12
0
        public void When_GetAudio_is_called_then_GetAudioAdapterSettings_on_the_BandRepository_is_called()
        {
            var tracks = AudioTrackCreator.CreateCollection();
            var entity = AdapterSettingsCreator.CreateSingle();

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            AudioAdapter
            .Expect(adapter =>
                    adapter.GetItems(entity.SetName, entity.OAuthAccessToken))
            .Return(tracks)
            .Repeat.Once();
            AudioAdapter.Replay();

            Process.GetAudioTracks();

            BandRepository.VerifyAllExpectations();
        }
Exemple #13
0
 public Uri GetAuthenticationUri(Uri callbackUrl)
 {
     return(AudioAdapter.GetOAuthCalculatedAuthorizationUri(callbackUrl));
 }
Exemple #14
0
        private void audioCursor()
        {
            try
            {
                string[] information =
                {
                    MediaStore.Audio.Media.InterfaceConsts.Id,
                    MediaStore.Audio.Media.InterfaceConsts.Data,
                    MediaStore.Audio.Media.InterfaceConsts.Track,
                    MediaStore.Audio.Media.InterfaceConsts.Year,
                    MediaStore.Audio.Media.InterfaceConsts.Duration,
                    MediaStore.Audio.Media.InterfaceConsts.AlbumId,
                    MediaStore.Audio.Media.InterfaceConsts.Album,
                    MediaStore.Audio.Media.InterfaceConsts.AlbumKey,
                    MediaStore.Audio.Media.InterfaceConsts.Title,
                    MediaStore.Audio.Media.InterfaceConsts.TitleKey,
                    MediaStore.Audio.Media.InterfaceConsts.ArtistId,
                    MediaStore.Audio.Media.InterfaceConsts.Artist
                };

                string orderBy = MediaStore.Audio.Media.InterfaceConsts.Id;


                //traer todas las listas de audio dentro del dispositivo movil consultando la memoria del movil
                ICursor audioCursor = ContentResolver.Query(MediaStore.Audio.Media.ExternalContentUri,
                                                            information, null, null, orderBy);

                #region nota 2
                //la informacion que me retorna la consulta
                #endregion

                _ID_Column      = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id);
                DATA_Column     = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data);
                YEAR_Column     = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Year);
                DURATION_Column = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Duration);
                ALBUM_ID_Column = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.AlbumId);
                ALBUM_Column    = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album);
                TRACK_Column    = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Title);
                ARTIST_Column   = audioCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Artist);
                //var c = true;
                while (audioCursor.MoveToNext())
                {
                    var audioTitle = audioCursor.GetString(TRACK_Column);
                    var artist     = audioCursor.GetString(ARTIST_Column);
                    var time       = audioCursor.GetString(DURATION_Column);
                    var time2      = convertDuration(Convert.ToInt64(time));
                    var arrPath    = audioCursor.GetString(DATA_Column);
                    items.Add(new Datos()
                    {
                        Title = audioTitle, Artist = artist, Time = time2, ArrPath = arrPath
                    });

                    //var audioTitle = "El Malo";
                    //var artist = "Aventura";
                    //var time = 3600000;
                    //var time2 = convertDuration(Convert.ToInt64(time));
                    //items.Add(new Datos() { Title = audioTitle, Artist = artist, Time = time2 });

                    //audioTitle = "Voy despues";
                    //artist = "El Nene La Amenaza";
                    //time = 90000;
                    //time2 = convertDuration(Convert.ToInt64(time));
                    //items.Add(new Datos() { Title = audioTitle, Artist = artist, Time = time2 });

                    //c = false;
                }
                audioCursor.Close();

                listData.Adapter = audioAdapter = new AudioAdapter(this, items);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Mensaje de error: " + ex.Message, ToastLength.Long).Show();
                Toast.MakeText(this, "Reinicie la aplicacion para una implementacion satisfactoria", ToastLength.Long).Show();

                //para cerrar la aplicacion
                //this.FinishAffinity();  //Cerrando todas las tareas
                //Finish();         //Ya cuando esta lista para cerrar
                //Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
            }
        }