コード例 #1
0
ファイル: ConvertService.cs プロジェクト: kactetus/Vitomu
        public void ProcessVideo(string uri)
        {
            try
            {
                // Get the audio format and bit rate from the settings
                AudioFormat format  = FileFormats.GetValidAudioFormat(SettingsClient.Get <string>("Output", "Format"));
                int         bitRate = FileFormats.GetValidBitRate(SettingsClient.Get <int>("Output", "BitRate"));

                // Create a temporary directory
                string tempFolder = Path.Combine(this.workingFolder, Guid.NewGuid().ToString());

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

                if (this.IsVideoUrl(uri))
                {
                    // Process the video URL
                    this.ConvertOnlineVideo(tempFolder, uri, format, bitRate);
                }
                else if (this.IsVideoFile(uri))
                {
                    // Process the video file
                    this.ConvertLocalVideo(tempFolder, uri, format, bitRate);
                }
            }
            catch (Exception ex)
            {
                LogClient.Error("An error occurred while processing the video. Exception: {0}", ex.Message);
                this.SetConvertState(ConvertState.Failed);
            }
        }
コード例 #2
0
ファイル: SettingsViewModel.cs プロジェクト: kactetus/Vitomu
        private async void GetAudioFormatsAsync()
        {
            var localAudioFormats = new ObservableCollection <AudioFormat>();

            await Task.Run(() =>
            {
                foreach (AudioFormat format in FileFormats.SupportedAudioFormats.OrderBy(f => f.Name))
                {
                    localAudioFormats.Add(format);
                }
            });

            this.AudioFormats = localAudioFormats;

            AudioFormat localSelectedAudioFormat = null;

            await Task.Run(() => localSelectedAudioFormat = FileFormats.GetValidAudioFormat(SettingsClient.Get <string>("Output", "Format")));

            this.SelectedAudioFormat = localSelectedAudioFormat;
        }