コード例 #1
0
        private async void ProcessButton_Click(object sender, System.EventArgs e)
        {
            if (sender is Button processButton)
            {
                processButton.Enabled = false;
            }

            Uri uri = null;
            try
            {
                var video = await MediaPicker.PickVideoAsync();
                var sourceFile = new File(video.FullPath);
                uri = Android.Net.Uri.FromFile(sourceFile);
                _sourceMedia.uri = uri;
                System.Diagnostics.Debug.WriteLine($"PickVideoAsync COMPLETED: {video.FullPath}");
            }
            catch (FeatureNotSupportedException err)
            {
                // Feature is not supported on the device
                System.Diagnostics.Debug.WriteLine($"PickVideoAsync FeatureNotSupportedException: {err.Message}");

            }
            catch (PermissionException err)
            {
                // Permissions not granted
                System.Diagnostics.Debug.WriteLine($"PickVideoAsync THREW PermissionException: {err.Message}");

            }
            catch (System.Exception err)
            {
                System.Diagnostics.Debug.WriteLine($"PickVideoAsync THREW: {err.Message}");
            }


            //            updateSourceMedia(sourceMedia, uri);
            //           updateTrimConfig(binding.getTrimConfig(), sourceMedia);
            var targetFile = new File(TransformationUtil.GetTargetFileDirectory(ApplicationContext), "transcoded_" + TransformationUtil.GetDisplayName(this, _sourceMedia.uri));
            //var targetFile = new File(FileSystem.CacheDirectory, "transcoded_" + TransformationUtil.GetDisplayName(this, _sourceMedia.uri) + ".mp4");

            // picked media
            updateSourceMedia(_sourceMedia, uri);


            //updateTrimConfig(_trimConfig, _sourceMedia);
            _trimConfig.setTrimEnd(_sourceMedia.duration * 0.5f);
            _trimConfig.setEnabled(true);

            _targetMedia.SetTargetFile(targetFile);
            _targetMedia.setTracks(_sourceMedia.tracks);
            _targetMedia.writeToWav = true;

            //ApplyWatermark(_sourceMedia, _targetMedia, _trimConfig, _transformationState);

            TranscodeAudio(_sourceMedia, _targetMedia, _trimConfig, _transformationState);

        }