Как написать программу Remote-Control для mplayer? - PullRequest
1 голос
/ 17 июня 2011

Мне нужно создать плагин NPAPI-Browser для управления mplayer, я обнаружил, что один из способов управления mplayer - это его подчиненный режим [ссылка] , есть ли другой способ лучше?

Ответы [ 3 ]

1 голос
/ 17 июня 2011

не твой вопрос, я знаю. но VLC имеет аналогичные уровни поддержки кодеков, встроенный веб-интерфейс, расширяемый с помощью сценариев lua, и все пух, который вы, возможно, не хотите (например, OSD), можно отключить. VLC также управляется через telnet, а библиотеки lua легко расширяются, чтобы обеспечить взаимодействие по сети или все, что вы захотите. Я написал плагин для управления последовательной линией.

0 голосов
/ 30 марта 2016

Я занимаюсь разработкой android phone remote control + VB.NET TCP server - mplayer. Я использую mplayer в режиме slave. Я посылаю команду из приложения для Android на VB.NET TCP сервер. Затем команда отправит в mplayer.

Я покажу некоторый код, который контролирует и отправляет mplayer нужные команды, но серверная часть еще не закончена. Кодирование еще не закончено, но я надеюсь, что оно вам пригодится.

Imports System.ComponentModel
Imports System.IO
Imports System.Data.OleDb
    Public Class Form1
      Private bw As BackgroundWorker = New BackgroundWorker
      Dim i As Integer = 0
      Dim dbFile As String = Application.StartupPath & "\Data\Songs.accdb"
      Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & dbFile & "; persist security info=false"
      Public conn As New OleDbConnection(connstring)
      Dim sw As Stopwatch
      Dim ps As Process = Nothing
      Dim jpgPs As Process = Nothing
      Dim args As String = Nothing
      Private Sub bw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
         Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)

         If bw.CancellationPending = True Then
             e.Cancel = True
             Exit Sub
         Else
        ' Perform a time consuming operation and report progress.
        'System.Threading.Thread.Sleep(500)
        bw.ReportProgress(i * 10)
        Dim dir_info As New DirectoryInfo(TextBox1.Text)
        ListFiels("SongList", TextBox2.Text, dir_info)
    End If

 End Sub

   Private Sub bw_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
    If e.Cancelled = True Then
        Me.tbProgress.Text = "Canceled!"
    ElseIf e.Error IsNot Nothing Then
        Me.tbProgress.Text = "Error: " & e.Error.Message
    Else
        Me.tbProgress.Text = "Done!"
    End If
End Sub

  Private Sub bw_ProgressChanged(ByVal sender As Object, ByVal e As ProgressChangedEventArgs)
       Me.tbProgress.Text = e.ProgressPercentage.ToString() & "%"
  End Sub

  Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Try
           ps.Kill()
        Catch
            Debug.Write("already closed")
        End Try
    End Sub


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False 'To avoid error from backgroundworker
    bw.WorkerReportsProgress = True
    bw.WorkerSupportsCancellation = True
    AddHandler bw.DoWork, AddressOf bw_DoWork
    AddHandler bw.ProgressChanged, AddressOf bw_ProgressChanged
    AddHandler bw.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted
    funPlayMusic()
End Sub

Private Sub buttonStart_Click(sender As Object, e As EventArgs) Handles buttonStart.Click
    If Not bw.IsBusy = True Then
        bw.RunWorkerAsync()
    End If
End Sub

Private Sub buttonCancel_Click(sender As Object, e As EventArgs) Handles buttonCancel.Click
    If bw.WorkerSupportsCancellation = True Then
        bw.CancelAsync()
    End If
End Sub

Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
    If Not bw.IsBusy = True Then
        sw = Stopwatch.StartNew()
        bw.RunWorkerAsync()
        sw.Stop()
        Label1.Text = ":   " + sw.Elapsed.TotalMilliseconds.ToString() + " ms"
    End If
End Sub
Private Sub ListFiels(ByVal tblName As String, ByVal pattern As String, ByVal dir_info As DirectoryInfo)
    i = 0
    Dim fs_infos() As FileInfo = Nothing
    Try
        fs_infos = dir_info.GetFiles(pattern)
    Catch ex As Exception
        MessageBox.Show(ex.ToString())
    End Try


    For Each fs_info As FileInfo In fs_infos
        i += 1
        Label1.Text = i
        insertData(tblName, fs_info.FullName)
        lstResults.Items.Add(i.ToString() + ":" + fs_info.FullName.ToString())
        If i = 1 Then
            Playsong(fs_info.FullName.ToString())
        Else
            i = 0
            lstResults.Items.Clear()
        End If
    Next fs_info
    sw.Stop()
    Label1.Text = ":   " + sw.Elapsed.TotalMilliseconds.ToString() + " ms"
    fs_infos = Nothing

    Dim subdirs() As DirectoryInfo = dir_info.GetDirectories()
    For Each subdir As DirectoryInfo In subdirs
        ListFiels(tblName, pattern, subdir)
    Next

End Sub
Private Sub insertData(ByVal tableName As String, ByVal foundfile As String)
    Try
        If conn.State = ConnectionState.Open Then conn.Close()
        conn.Open()

        Dim SqlQuery As String = "INSERT INTO " & tableName & " (SngPath) VALUES (@sng)"
        Dim SqlCommand As New OleDbCommand
        With SqlCommand
            .CommandType = CommandType.Text
            .CommandText = SqlQuery
            .Connection = conn
            .Parameters.AddWithValue("@sng", foundfile)
            .ExecuteNonQuery()
        End With

        conn.Close()
    Catch ex As Exception
        conn.Close()
        MsgBox(ex.Message)
    End Try
End Sub


Private Sub btnClearList_Click(sender As Object, e As EventArgs) Handles btnClearList.Click
    lstResults.Items.Clear()
End Sub

Private Sub funPlayMusic()

    ps = New Process()
    ps.StartInfo.FileName = "D:\Music\mplayer.exe "
    ps.StartInfo.UseShellExecute = False
    ps.StartInfo.RedirectStandardInput = True
    jpgPs = New Process()
    jpgPs.StartInfo.FileName = "D:\Music\playjpg.bat"
    jpgPs.StartInfo.UseShellExecute = False
    jpgPs.StartInfo.RedirectStandardInput = True
    'ps.StartInfo.CreateNoWindow = True
    args = "-fs  -noquiet -identify -slave " '
    args += "-nomouseinput -sub-fuzziness 1 "
    args += " -vo direct3d, -ao dsound "
    '    -wid will tell MPlayer to show output inisde our panel
    '    args += " -vo direct3d, -ao dsound  -wid ";
    '    int id = (int)panel1.Handle;
    '    args += id;
End Sub
Public Function SendCommand(ByVal cmd As String) As Boolean
    Try
        If ps IsNot Nothing AndAlso ps.HasExited = False Then
            ps.StandardInput.Write(cmd + vbLf)
            'MessageBox.Show(ps.StandardOutput.ReadToEndAsync.ToString())
            Return True
        Else
            Return False
        End If

    Catch ex As Exception
        Return False
    End Try
End Function

Public Sub Playsong(ByVal Songfilelocation As String)

    Try
        ps.Kill()
    Catch
    End Try
    Try
        ps.StartInfo.Arguments = args + " """ + Songfilelocation + """"
        ps.Start()

        SendCommand("set_property volume " + "80")
    Catch e As Exception
        MessageBox.Show(e.Message)
    End Try

End Sub

Private Sub lstResults_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstResults.SelectedIndexChanged
    Playsong(lstResults.SelectedItem.ToString())
End Sub



Private Sub btnPlayJPG_Click(sender As Object, e As EventArgs) Handles btnPlayJPG.Click
    Try
        ' jpgPs.Kill()
    Catch
    End Try
    Try
        'ps.StartInfo.Arguments = "–fs –mf fps=5 mf://d:/music/g1/Image00020.jpg –loop 200" '-vo gl_nosw
        'jpgPs.Start()
        Shell("d:\Music\playjpg.bat")

        ' SendCommand("set_property volume " + "80")
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub


Private Sub btnPlayPause_Click(sender As Object, e As EventArgs) Handles btnPlayPause.Click
    SendCommand("pause")

End Sub

Private Sub btnMute_Click(sender As Object, e As EventArgs) Handles btnMute.Click
    SendCommand("mute")
End Sub

Private Sub btnKaraoke_Click(sender As Object, e As EventArgs) Handles btnKaraoke.Click
    'SendCommand("panscan 0-0 | 1-1")
    SendCommand("af_add pan=2:1:1:0:0")


End Sub

Private Sub btnStereo_Click(sender As Object, e As EventArgs) Handles btnStereo.Click
    SendCommand("af_add pan=2:0:0:1:1")
End Sub

Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
    Playsong("d:\music\iot.mp4")
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    'SendCommand("loadfile d:\music\iot.mp4")
    'SendCommand("pt_step 1")

End Sub

End Class
0 голосов
/ 21 июня 2011

Обнаружено, что подчиненный режим mplayer - единственный способ, ftp: //ftp2.mplayerhq.hu/MPlayer/DOCS/tech/slave.txt

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...