2
就我而言,我有一個簡單的RTMP實時音頻流(例如:rtmp:// myserver/myapp/myliveaudio)。如何在android中播放RTMP的音頻鏈接?
在我的Android應用程序中讀取它的最簡單方法是什麼?
就我而言,我有一個簡單的RTMP實時音頻流(例如:rtmp:// myserver/myapp/myliveaudio)。如何在android中播放RTMP的音頻鏈接?
在我的Android應用程序中讀取它的最簡單方法是什麼?
你可以簡單地嘗試使用的WebView
public class Player extends Activity implements OnClickListener {
WebView webView;
String bodyHtml;
String rtmpUrl;
String fileName;
Button refreshButton;
String htmlPost = "</body></html>";
String htmlPre = "<!DOCTYPE html>"
+ "<html lang=\"en\">"
+ "<head><meta charset=\"utf-8\">"
+ "</head>"
+ "<body style='margin:0; pading:0;"
+ " background-color: #71D5CA;'>";
String htmlCode = "<embed "
+ "type=\"application/x-shockwave-flash\""
+ "id=\"player1\" " + "name=\"player1\" "
+ "src=\"http://developer.longtailvideo.com"
+ "/svn/trunk/fl5/player.swf\""
+ "width=\"320\""
+ "height=\"280\"" + " [email protected]@"
+ "allowfullscreen=\"true\""
+ "allowscripaccess=\"always\""
+ "/> ";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setAppCacheEnabled(true);
refreshButton =
(Button) findViewById(R.id.main_bt_refresh);
refreshButton.setOnClickListener(this);
refreshFileName();
}
@Override
public void onClick(View v) {
refreshFileName();
}
private void refreshFileName() {
EditText etRtmpUrl =
(EditText) findViewById(R.id.setup_et_host);
EditText etFileName =
(EditText) findViewById(R.id.setup_et_file);
rtmpUrl = etRtmpUrl.getText().toString();
fileName = etFileName.getText().toString();
if (fileName.endsWith(".flv")) {
fileName = "flv:" + fileName;
}
bodyHtml = htmlCode;
bodyHtml = bodyHtml.replaceAll("@[email protected]",
"\"file=" + fileName
+ "&streamer=" + rtmpUrl + "\"");
webView.loadDataWithBaseURL("http://127.0.0.1",
htmlPre + bodyHtml
+ htmlPost, "text/html", "UTF-8", null);
}
}
檢查這個項目,例如連接:
我的RTMP網址是現場直播的網址,那麼應該怎麼傳遞文件名? –