Exemplo n.º 1
0
        private void PlayButton_Clicked(object sender, EventArgs e)
        {
            try
            {
                if (audioPlayer == null)
                {
                    audioPlayer = CrossSimpleAudioPlayer.Current;
                }

                if (audioPlayer.IsPlaying)
                {
                    audioPlayer.Stop();

                    RecordButton.IsEnabled = true;
                    UploadButton.IsEnabled = true;

                    PlayButton.Text = AppResources.Play;

                    voiceFileStream?.Close();
                }
                else
                {
                    if (!File.Exists(recordFilePath))
                    {
                        if (!FTPService.DownloadFile(AppEnvironment.dataService.ServerUserDataDirPath, recordFilePath))
                        {
                            throw new Exception("Cannot download record file");
                        }
                    }

                    voiceFileStream?.Close();
                    voiceFileStream = new FileStream(recordFilePath, FileMode.Open, FileAccess.Read);

                    audioPlayer.Load(voiceFileStream);
                    audioPlayer.Play();
                    audioPlayer.PlaybackEnded += delegate
                    {
                        RecordButton.IsEnabled = true;
                        UploadButton.IsEnabled = true;

                        PlayButton.Text = AppResources.Play;

                        voiceFileStream?.Close();
                    };

                    RecordButton.IsEnabled = false;
                    UploadButton.IsEnabled = false;

                    PlayButton.Text = AppResources.Stop;
                }
            }
            catch (Exception ex)
            {
                DependencyService.Get <IToast>().Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private async Task <int> SyncRasp()
        {
            string   dir    = Path.Combine(Server.MapPath("~/CSV/"));
            FileInfo dirCSV = new FileInfo(dir + "toque.csv");

            dirCSV.Delete();

            await FTPService.DownloadFile(dir, "csv");

            dir = Path.Combine(Server.MapPath("~/Musicas/"));

            DirectoryInfo di = new DirectoryInfo(dir);

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            return(1);
        }
Exemplo n.º 3
0
        private void CheckFirstVoiceStatusFile()
        {
            string filePath   = Path.Combine(LocalDataPath, firstVoiceSetStatusFile);
            string serverPath = Path.Combine(ServerUserDataDirPath, firstVoiceSetStatusFile);

            if (!Directory.Exists(LocalDataPath))
            {
                Directory.CreateDirectory(LocalDataPath);
            }

            if (!File.Exists(filePath))
            {
                if (FTPService.CheckFileExist(serverPath))
                {
                    FTPService.DownloadFile(filePath, serverPath);
                }
                else
                {
                    File.WriteAllText(filePath, "");
                }
            }
        }
Exemplo n.º 4
0
        public bool DownloadTable()
        {
            string serverPath = Path.Combine(FTPService.CheckDirExist(ServerUserDataDirPath) ? ServerUserDataDirPath : ServerDefaultDataDirPath, serverFile);

            return(FTPService.DownloadFile(LocalDataFilePath, serverPath));
        }