国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開(kāi)通VIP
支持FLV視頻在線快速拖放的java服務(wù)器端代碼 - 戰(zhàn)楠的日志 - 網(wǎng)易博客

支持提交http://domain/flvfile.flv?show&start=number1&end=number2參數(shù)拖放的FLV播放器,

修改播放器,支持播放時(shí)僅下載需要的幾分鐘視頻,測(cè)試地址:

http://www.baowei.org/flv/flv.html  http://www.baowei.org/flv/m4v.html 

flv文件需要經(jīng)過(guò)FLVMDI等工具添加了“關(guān)鍵幀”對(duì)象。

支持FLV視頻在線快速拖放的java服務(wù)器端代碼,Servlet程序。

package org.baowei.cdn;

import java.io.RandomAccessFile;

import java.io.FileNotFoundException;

importjavax.servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;

importjavax.servlet.http.HttpServletResponse;

import javax.servlet.http.Cookie;

public class flv extends HttpServlet {

 public flv() {

 }

 public void doGet(HttpServletRequest request,HttpServletResponse response) {

  booleanrightCookie = false;

  Cookie[]cookies = request.getCookies();

  if(request.getHeader("x-flash-version") != null && cookies !=null) {

   P: for (int i = 0; i <cookies.length; i++) {

    if(cookies[i].getName().startsWith("webMaster")) {

     // 防止盜鏈

     rightCookie= true;

     break P;

    }

   }

  }

  exit:if (rightCookie) {

   // format:

   // http://127.0.0.1:8080/cdn/flv?httpurl=http://www.baowei.org/flvfiles/a.flv?show&start=123&end=456

   String httpurl = "", localfile = "";

   int start = 0, end = 0;

   RandomAccessFile raf = null;

   try {

    httpurl= new String(request.getParameter("httpurl").getBytes(

      "ISO8859_1"), "GBK");

    if (httpurl.lastIndexOf("?show") == -1) {

     break exit;

    } else

     localfile= "/squid2/"

       +httpurl.substring(7, httpurl.length() - 5);

    try {

     start =Integer.parseInt(request.getParameter("start"));

    } catch (Exception e0) {

    }

    try{

     end =Integer.parseInt(request.getParameter("end"));

    } catch (Exception e0) {

    }

    response.reset();

    response.setContentType("video/x-flv");

    

    raf= new RandomAccessFile(localfile, "r");

    int length = (int) raf.length();

    if (end == 0)

     length =length - start;

    else

     length = end - start;

    // 當(dāng)不是從頭讀起時(shí),Add Flv header!

    byte[] data = new byte[] { 'F', 'L','V', 1, 1, 0, 0, 0, 9, 0,

      0, 0, 9};

    if (start > 0) {

     response.setContentLength(length + 13);

     response.getOutputStream().write(data);

    } else

     response.setContentLength(length);

    data = new byte[1024];

    raf.skipBytes(start);

    for (int j = 0; j < length / 1024;j++) {

     raf.read(data);

     response.getOutputStream().write(data);

    }

    data= new byte[length % 1024];

    raf.read(data);

    response.getOutputStream().write(data);

    response.getOutputStream().flush();

   } catch (FileNotFoundException e1) {

    try {

     //資源文件不存在,跳轉(zhuǎn)到源站。

     response.sendRedirect("http://src_" + httpurl.substring(7)

       + "?show&start=" + start +"&end=" + end);

    } catch(Exception e2) {

    }

   } catch (Exception e3) {

   } finally {

    try {

     raf.close();

    } catch (Exception e4) {

    }

   }

  } else {

   try {

    // 盜鏈URL跳轉(zhuǎn)

    response.sendRedirect("

   } catch (Exception e5) {

   }

  }

  this.destroy();

 }

}

打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Flex 向 Java 調(diào)用
臺(tái)北故宮
Java多線程文件復(fù)制
axis1.4與myeclipse開(kāi)發(fā)webservice
Java讀MP3 文件的頭信息(ID3V1) — JAVA頻道
Ext與后臺(tái)數(shù)據(jù)庫(kù)交互
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服