我正在创建一个在$products = array();
foreach($_POST['selected_checkboxes'] as $value) {
var_dump($value);
if($result = $db->query("SELECT * FROM produkte WHERE `$value` = 1")){
while($row = $result->fetch_object()) {
if (!in_array($row->name, $products)) {
array_push( $products, array('name'=>$row->name, 'image'=>$row->image, 'link'=>$row->link) );
}
}
}
else {
array_push($products, 'error');
}
}
上运行mediaplayer
的Android应用程序,以及来自互联网的流媒体视频。现在,我想将相同的流视频记录到.mp4文件(或任何格式)到SD卡。我怎么能这样做?
我无法使用textureview
代替surfaceview
。请帮帮我。
答案 0 :(得分:0)
我有一个解决方案。如果服务器支持下载,请使用以下代码。
private final int TIMEOUT_CONNECTION = 5000; //5sec
private final int TIMEOUT_SOCKET = 30000; //30sec
private final int BUFFER_SIZE = 1024 * 5; // 5MB
try {
URL url = new URL("http://....");
//Open a connection to that URL.
URLConnection ucon = url.openConnection();
ucon.setReadTimeout(TIMEOUT_CONNECTION);
ucon.setConnectTimeout(TIMEOUT_SOCKET);
// Define InputStreams to read from the URLConnection.
// uses 5KB download buffer
InputStream is = ucon.getInputStream();
BufferedInputStream in = new BufferedInputStream(is, BUFFER_SIZE);
FileOutputStream out = new FileOutputStream(file);
byte[] buff = new byte[BUFFER_SIZE];
int len = 0;
while ((len = in.read(buff)) != -1)
{
out.write(buff,0,len);
}
} catch (IOException ioe) {
// Handle the error
} finally {
if(in != null) {
try {
in.close();
} catch (Exception e) {
// Nothing you can do
}
}
if(out != null) {
try {
out.flush();
out.close();
} catch (Exception e) {
// Nothing you can do
}
}
}
它会有所帮助。谢谢