자바 호출 mplayer
http://beradrian.wordpress.com/2008/01/30/jmplayer/
qt:
http://www.embedu.org/Column/Column140.htm
http://tingxx.ycool.com/post.2028303.html
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
class LineRedirecter extends Thread {
/** The input stream to read from. */
private InputStream in;
/** The output stream to write to. */
private OutputStream out;
/**
* @param in the input stream to read from.
* @param out the output stream to write to.
* @param prefix the prefix used to prefix the lines when outputting to the logger.
*/
LineRedirecter(InputStream in, OutputStream out) {
this.in = in;
this.out = out;
}
public void run()
{
try {
// creates the decorating reader and writer
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
PrintStream printStream = new PrintStream(out);
String line;
// read line by line
while ( (line = reader.readLine()) != null) {
printStream.println(line);
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
public class MyPlayer {
public static void main(String[] args) {
try{
// create the piped streams where to redirect the standard output and error of MPlayer
// specify a bigger pipesize than the default of 1024
PipedInputStream readFrom = new PipedInputStream(256*1024);
PipedOutputStream writeTo = new PipedOutputStream(readFrom);
BufferedReader mplayerOutErr = new BufferedReader(new InputStreamReader(readFrom));
Process mplayerProcess = Runtime.getRuntime().exec("e:/player.exe c:/media/video/1.mov");//-quiet -idle -slave
// create the threads to redirect the standard output and error of MPlayer
new LineRedirecter(mplayerProcess.getInputStream(), writeTo).start();
new LineRedirecter(mplayerProcess.getErrorStream(), writeTo).start();
// the standard input of MPlayer
PrintStream mplayerIn = new PrintStream(mplayerProcess.getOutputStream());
mplayerIn.print("set_property time_pos 300");
mplayerIn.print("
");
mplayerIn.flush();
mplayerIn.print("loadfile \"c:/media/video/1.mov\" 0");
mplayerIn.print("
");
mplayerIn.flush();
mplayerIn.print("pause");
mplayerIn.print("
");
mplayerIn.flush();
mplayerIn.print("get_property length");
mplayerIn.print("
");
mplayerIn.flush();
String answer;
int totalTime = -1;
try {
while ((answer = mplayerOutErr.readLine()) != null) {
if (answer.startsWith("ANS_length=")) {
totalTime = Integer.parseInt(answer.substring("ANS_length=".length()));
break;
}
}
}
catch (IOException e) {
}
System.out.println("========"+totalTime);
try {
mplayerProcess.waitFor();
}
catch (InterruptedException e) {}
}catch (Exception e) {
}
}
}
예 를 들 어 windows 판 mplayer 입 니 다.이 예 는 기본 호출 입 니 다.필요 하 시 면 mplayer 매 뉴 얼 을 보 세 요.
http://wuzijingaip.iteye.com/admin/blogs/545229
자바 오픈 소스 만능 플레이어 의 한 단락
/*
* :[email protected]
* :http://hi.baidu.com/mqlayer
*/
package player;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.peer.ComponentPeer;
import javax.swing.JPanel;
public class VideoPanel extends JPanel{
private static final long serialVersionUID = 4417214835406666167L;
Player player;
Canvas canvas;
VideoPanel(Player pl){
player=pl;
setBackground(new Color(3,3,3));
setLayout(new VideoLayout(player));
canvas=new Canvas();
add(canvas);
canvas.setName("canvas");
canvas.setBackground(new Color(3,3,3));
}
// window handle
@SuppressWarnings("deprecation")
long getWid(){
long wid=-1;
try {
Class<?> cl = Class.forName("sun.awt.windows.WComponentPeer");
java.lang.reflect.Field f = cl.getDeclaredField("hwnd");
f.setAccessible(true);
ComponentPeer peer = canvas.getPeer();
wid = f.getLong(peer);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("wid:" + wid );
return wid;
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.