ijkplayer 视频播放

导入依赖

  implementation 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'

AndroidManifest.xml加入权限

  
  
  
  

布局文件

 

在activity中

public class ProductDataActivity extends AppCompatActivity {

    @BindView(R.id.webview)
    WebView webview;
    @BindView(R.id.shopcart)
    TextView shopcart;
    private PlayerView playerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product_data);
        ButterKnife.bind(this);

        playerView = new PlayerView(this)
                .setTitle("视频播放")
                .setScaleType(PlayStateParams.fitparent)
                .hideMenu(false)
                .setPlaySource("http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4")
                .startPlay();


        webview.setWebChromeClient(new WebChromeClient());
        webview.loadUrl(getIntent().getStringExtra("detailUrl"));

        shopcart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                 Toast.makeText(getApplication(),"下单成功",Toast.LENGTH_SHORT).show();
            }
        });

    }

    @Override
    protected void onStop() {
        super.onStop();
        playerView.stopPlay();
    }
}

你可能感兴趣的:(原创)