|
2017/02/25(Sat) 15:45:32 編集(投稿者) 2017/02/25(Sat) 15:43:56 編集(投稿者) 2017/02/25(Sat) 15:30:14 編集(投稿者)
> そのエラーが出たときのコードも書いた方が良いと思いますよ。 > でないと、先に進みませんので…。 回答ありがとうございます。 そうします。長いコードなのですが、貼ってみたいと思います。 要らない部分も多いのかな・・・とおもいながら、 わからないので貼っておきます。 デザインのほうはあったほうが良ければ言ってください。(ソースコードあればなんとなくわかるかな・・・?)
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− Imports System.IO Imports System.Drawing.Color Imports System.Text.Encoding
Public Class Form1 Dim UserName As String = Environment.UserName Dim FileLength As Byte = 0 'For Concat Dim sw As New Stopwatch()
Private Sub Form1_load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load Output.Text = ("C:\Users\" & UserName & "\Desktop\Output.mp3") End Sub Private Sub TextBox7_DragDrop(sender As Object, e As DragEventArgs) Handles TextBox7.DragDrop FileLength = FileLength + 1 Dim FileName = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())(0) TextBox7.AppendText(" -i" + " " + Chr(34) + FileName + Chr(34)) End Sub
Private Sub TextBox7_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox7.DragEnter If (e.Data.GetDataPresent(DataFormats.FileDrop)) = True Then e.Effect = DragDropEffects.All Else e.Effect = DragDropEffects.None End If End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim EncodeYN As DialogResult = MessageBox.Show("Are you sure to encode now??", "Check", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If EncodeYN = DialogResult.OK Then '========================================= Dim test As String = 0 Dim text As String = TextBox7.Text
'====================================================================================2017/02/09
'Concat or not If (Button2.Text = "ON") Then TextBox8.Text = ("ffmpeg" & text & " -filter_complex " & Chr(34) & "concat=n=" & FileLength & ":v=0:a=1" & Chr(34)) Else TextBox8.Text = ("ffmpeg" & text) End If
'Channel If (Channel.Value <> 0) Then TextBox8.Text = (TextBox8.Text & " -ac " & Channel.Value) End If
'BitRate If (BitRate.Text <> String.Empty) Then TextBox8.Text = (TextBox8.Text & " -ab " & BitRate.Text) End If
'Sampling If (Sampling.Text <> String.Empty) Then TextBox8.Text = (TextBox8.Text & " -ar " & Sampling.Text) End If
'Volume Select Case (Volume.Text) Case String.Empty, "256", "0" 'Do nothing Case Else TextBox8.Text = (TextBox8.Text & " -vol " & Volume.Text) End Select
TextBox8.Text = (TextBox8.Text & Chr(32) & Output.Text & "\" & OutputName.Text) '================================================================================END
'-------Same OutPutName Check--------- If File.Exists(text) Then MessageBox.Show("File name is already exists , Please type another name") Return End If
'============== dobon.net ここから ================ Dim p As New System.Diagnostics.Process()
'出力とエラーをストリームに書き込むようにする p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardOutput = True p.StartInfo.RedirectStandardError = True 'OutputDataReceivedとErrorDataReceivedイベントハンドラを追加 AddHandler p.OutputDataReceived, AddressOf p_OutputDataReceived AddHandler p.ErrorDataReceived, AddressOf p_ErrorDataReceived
p.StartInfo.FileName = _ System.Environment.GetEnvironmentVariable("ComSpec") p.StartInfo.RedirectStandardInput = False p.StartInfo.CreateNoWindow = True p.StartInfo.Arguments = textbox8.text
'起動 p.Start()
'非同期で出力とエラーの読み取りを開始 p.BeginOutputReadLine() p.BeginErrorReadLine()
p.WaitForExit() p.Close()
Console.ReadLine() End Sub ElseIf EncodeYN = DialogResult.Cancel Then
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If (Button2.BackColor = White) Then Button2.Text = "ON" Button2.BackColor = CornflowerBlue Button2.ForeColor = White ElseIf (Button2.BackColor = CornflowerBlue) Then Button2.Text = "OFF" Button2.BackColor = White Button2.ForeColor = Black Else MessageBox.Show("Something wrong with inside the program...") End If End Sub
Private Sub Change_Click(sender As Object, e As EventArgs) Handles Change.Click 'Create Instance (folder browser dialog) Dim fbd As New FolderBrowserDialog 'Description fbd.Description = "Set Output Folder..." 'root folder (Default : desktop) fbd.RootFolder = Environment.SpecialFolder.Desktop 'First Directory , need under the root folder fbd.SelectedPath = Environment.SpecialFolder.Desktop 'Can make new folder (Default : true) fbd.ShowNewFolderButton = True 'Show Dialog If fbd.ShowDialog(Me) = DialogResult.OK Then Output.Text = fbd.SelectedPath End If
End Sub
Private Sub AboutMe_Click(sender As Object, e As EventArgs) Handles AboutMe.Click MessageBox.Show("Created By XXXX , XXXX", "(c) XXXX", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class
'OutputDataReceivedイベントハンドラ '行が出力されるたびに呼び出される Private Shared Sub p_OutputDataReceived(sender As Object, _ e As System.Diagnostics.DataReceivedEventArgs) '出力された文字列を表示する textbox1.appendtext(e.Data) End Sub
'ErrorDataReceivedイベントハンドラ Private Shared Sub p_ErrorDataReceived(sender As Object, _ e As System.Diagnostics.DataReceivedEventArgs) 'エラー出力された文字列を表示する textbox1.appendtext("ERR>{0}", e.Data) End Sub −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− こんな感じです。 </pre></pre>
|