Example usage for android.webkit URLUtil decode

List of usage examples for android.webkit URLUtil decode

Introduction

In this page you can find the example usage for android.webkit URLUtil decode.

Prototype

public static byte[] decode(byte[] url) throws IllegalArgumentException 

Source Link

Usage

From source file:com.youku.player.base.YoukuBasePlayerActivity.java

public void playNoRightVideo(String mUri) { //unused

    if (mUri == null || mUri.trim().equals("")) {
        Profile.from = Profile.PHONE;/*from  w ww  .  j  a  va  2  s. co m*/
        return;
    }
    if (mUri.startsWith("youku://")) {
        mUri = mUri.replaceFirst("youku://", "http://");
    } else {
        Profile.from = Profile.PHONE;
        return;
    }
    // ????????
    // initPlayAndSurface();
    if (mediaPlayerDelegate.videoInfo == null)
        mediaPlayerDelegate.videoInfo = new VideoUrlInfo();
    final int queryPosition = mUri.indexOf("?");
    if (queryPosition != -1) {
        String url = new String(URLUtil.decode(mUri.substring(0, queryPosition).getBytes()));
        if (PlayerUtil.useUplayer()) {
            StringBuffer m3u8Url = new StringBuffer();
            m3u8Url.append("#PLSEXTM3U\n#EXT-X-TARGETDURATION:10000\n")
                    .append("#EXT-X-VERSION:2\n#EXT-X-DISCONTINUITY\n").append("#EXTINF:10000\n").append(url)
                    .append("\n#EXT-X-ENDLIST\n");
            mediaPlayerDelegate.videoInfo.setUrl(m3u8Url.toString());
        } else {
            mediaPlayerDelegate.videoInfo.setUrl(url);
        }
        String[] params = mUri.substring(queryPosition + 1).split("&");
        for (int i = 0; i < params.length; i++) {
            String[] param = params[i].split("=");
            if (param[0].trim().equals("vid")) {
                mediaPlayerDelegate.videoInfo.setVid(param[1].trim());
            }
            if (param[0].trim().equals("title")) {
                try {
                    mediaPlayerDelegate.videoInfo.setTitle(URLDecoder.decode(param[1].trim(), "UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }
    } else {
        return;
    }
    onParseNoRightVideoSuccess();
}