Esempio n. 1
0
        async void OnAlbumItemClicked(object sender, AdapterView.ItemClickEventArgs e)
        {
            var selectedEpisode = _album.Episodes [e.Position];

            if (AndroidAudioDownloader.ViewsDownloadInProgressByAudioId.ContainsKey(selectedEpisode.RemoteUrl))
            {
                return;
            }

            if (AudioDownloader.HasLocalFile(selectedEpisode.RemoteUrl, selectedEpisode.FileSize))
            {
                var resultIntent = new Intent();
                ExtraUtils.PutEpisode(resultIntent, selectedEpisode.Id);
                ExtraUtils.PutAlbum(resultIntent, _album.Id);
                ExtraUtils.PutSelectedTab(resultIntent, (int)MainActivity.TabTitle.Player);
                SetResult(Result.Ok, resultIntent);

                StartService(PlayerService.CreateIntent(
                                 this,
                                 PlayerService.ACTION_PLAY,
                                 _album.Id,
                                 selectedEpisode.Id
                                 ));

                Finish();
            }
            else
            {
                await AndroidAudioDownloader.StartDownloadAsync(e.Position, selectedEpisode.RemoteUrl, ListView);
            }
        }
        void SendAudioCommand(string action)
        {
            var intent = PlayerService.CreateIntent(Activity, action);

            if (!IsBound)
            {
                Activity.BindService(intent, _connection, Bind.AutoCreate);
            }

            Activity.StartService(intent);
        }