{"id":526,"date":"2017-11-21T15:25:59","date_gmt":"2017-11-21T07:25:59","guid":{"rendered":"https:\/\/www.dd-home.top\/?p=526"},"modified":"2017-11-21T15:25:59","modified_gmt":"2017-11-21T07:25:59","slug":"vlc-%e7%9a%84%e6%92%ad%e6%94%be%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.dd-home.top\/?p=526","title":{"rendered":"VLC \u7684\u64ad\u653e\u529f\u80fd"},"content":{"rendered":"<p><!--more--><\/p>\n<p>TMD,\u540e\u671f\u6162\u6162\u66f4\u65b0\u4e0b<\/p>\n<p><code><\/code><\/p>\n<pre>try {\n    \/\/ get the output stream to write to\n    OutputStream outputStream = response.getOutputStream();\n    response.setContentType(\"multipart\/x-mixed-replace; boundary=--BoundaryString\");\n    response.setHeader(\"Connection\", \"close\");\n    response.setHeader(\"Max-Age\", \"0\");\n    response.setHeader(\"Expires\", \"0\");\n    response.setHeader(\"Cache-Control\", \"no-cache, private\");\n    response.setHeader(\"Pragma\", \"no-cache\");\n    \/\/ loop over and send the images while the browser is present and listening, then return\n    File files = new File(\"D:\\My Projects\\Monitor\\test1\");\n    for (File f : files.listFiles()) {\n        BufferedImage image = ImageIO.read(f);\n        ByteArrayOutputStream baos = new ByteArrayOutputStream();\n        ImageIO.write(image, \"jpg\", baos);\n        byte[] imageData = baos.toByteArray();\n        outputStream.write((\"--BoundaryStringrn\" + \"Content-type: image\/jpegrn\" + \"Content-Length: \" + imageData.length + \"rnrn\").getBytes());\n        outputStream.write(imageData);\n        outputStream.write(\"rnrn\".getBytes());\n        outputStream.flush();\n\n        \/\/ force sleep to not overwhelm the browser, simulate ~20 FPS\n        \/\/ TimeUnit.MILLISECONDS.sleep(1000 \/ 50);\n    }\n    outputStream.flush();\n    outputStream.close();\n} catch (Exception e) {\n    e.printStackTrace();\n}<\/pre>\n<p><code><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-526","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=526"}],"version-history":[{"count":0,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/526\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}