Пример #1
0
        protected async void loadFromFile(string mFilename)
        {
            mFile = new File(mFilename);
            mLoadingLastUpdateTime = JavaSystem.CurrentTimeMillis();
            mProgressDialog        = new ProgressDialog(Context);
            mProgressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal);
            mProgressDialog.SetTitle("progress_dialog_loading");
            mProgressDialog.SetCancelable(true);

            mProgressDialog.Show();

            await Task.Run(() =>
            {
                _cheapSoundFile = CheapSoundFile.Create(App.SelectedFilePath, new ProgressListener()
                {
                    ReportProgressCallback = fractionComplete =>
                    {
                        long now = JavaSystem.CurrentTimeMillis();
                        if (now - mLoadingLastUpdateTime > 100)
                        {
                            mProgressDialog.Progress =
                                (int)(mProgressDialog.Max * fractionComplete);
                            mLoadingLastUpdateTime = now;
                        }
                    }
                });

                new Handler(Looper.MainLooper).Post(() => { finishOpeningSoundFile(); });
            });
        }
Пример #2
0
        private async Task LoadFile()
        {
            var file = new File(SongFilePath);

            var progressDialog = new ProgressDialog(this);

            await Task.Run(() =>
            {
                try
                {
                    _soundFile = CheapSoundFile.Create(SongFilePath, this);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                finally
                {
                    _waveformView.SetSoundFile(_soundFile);
                    _waveformView.RecomputeHeights(2);

                    var mPos = _waveformView.MaxPos();
                }
            });
        }