package fm.jiecao.jiecaovideoplayer;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.AbsoluteLayout;

import com.squareup.picasso.Picasso;

import fm.jiecao.jcvideoplayer_lib.JCUtils;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

/**
 * Created by Nathen on 16/10/13.
 */

public class WebViewActivity extends AppCompatActivity {
    WebView mWebView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.addJavascriptInterface(new JCCallBack(), "jcvd");
        mWebView.loadUrl("file:///android_asset/jcvd.html");
    }

    public class JCCallBack {

        @JavascriptInterface
        public void adViewJieCaoVideoPlayer(final int width, final int height, final int top, final int left) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    JCVideoPlayerStandard webVieo = new JCVideoPlayerStandard(WebViewActivity.this);
                    webVieo.setUp("http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4",
                            JCVideoPlayer.SCREEN_LAYOUT_LIST, "嫂子好困");
                    Picasso.with(WebViewActivity.this)
                            .load("http://cos.myqcloud.com/1000264/qcloud_video_attachment/842646334/vod_cover/cover1458036374.jpg")
                            .into(webVieo.thumbImageView);
                    ViewGroup.LayoutParams ll = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(ll);
                    layoutParams.y = JCUtils.dip2px(WebViewActivity.this, top);
                    layoutParams.x = JCUtils.dip2px(WebViewActivity.this, left);
                    layoutParams.height = JCUtils.dip2px(WebViewActivity.this, height);
                    layoutParams.width = JCUtils.dip2px(WebViewActivity.this, width);
                    mWebView.addView(webVieo, layoutParams);
                }
            });

        }
    }
}

@@ -180,16 +180,46 @@
 tivity;%0A
+import android.view.MenuItem;%0A
 import a
@@ -789,24 +789,333 @@
 anceState);%0A
+        getSupportActionBar().setDisplayHomeAsUpEnabled(true);%0A        getSupportActionBar().setDisplayShowHomeEnabled(true);%0A        getSupportActionBar().setDisplayShowTitleEnabled(true);%0A        getSupportActionBar().setDisplayUseLogoEnabled(false);%0A        getSupportActionBar().setTitle(%22AboutWebView%22);%0A
         setC
@@ -2908,11 +2908,547 @@
  %7D%0A    %7D
+%0A%0A    @Override%0A    public void onBackPressed() %7B%0A        if (JCVideoPlayer.backPress()) %7B%0A            return;%0A        %7D%0A        super.onBackPressed();%0A    %7D%0A%0A    @Override%0A    protected void onPause() %7B%0A        super.onPause();%0A        JCVideoPlayer.releaseAllVideos();%0A    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A            case android.R.id.home:%0A                finish();%0A                break;%0A        %7D%0A        return super.onOptionsItemSelected(item);%0A    %7D
 %0A%7D%0A

complete activity