Android_播放视频的多种方式 Ijkplayer 与 jiecao

方式一:jiecao

依赖

compile 'fm.jiecao:jiecaovideoplayer:4.8.3'
布局

代码

boolean setUp = videoplayer.setUp("视频地址", JCVideoPlayer.SCREEN_LAYOUT_LIST, "视频名称");
            if (setUp) {
                videoplayer.thumbImageView.setScaleType(ImageView.ScaleType.FIT_XY);
                Glide.with(this).load("图片地址").into(videoplayer.thumbImageView);
            }
    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }
    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }






方式二:Ijkplayer

依赖

compile 'com.github.leifzhang:IjkLib:0.4.3'
布局

  

主页面

package com.example.ijkplayer3;

import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import tv.danmaku.ijk.media.widget.media.AndroidMediaController;
import tv.danmaku.ijk.media.widget.media.IjkVideoView;

public class MainActivity extends AppCompatActivity {

    private IjkVideoView ijkPlayer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        IjkMediaPlayer.loadLibrariesOnce(null);
        IjkMediaPlayer.native_profileBegin("libijkplayer.so");

        ijkPlayer =  (IjkVideoView)findViewById(R.id.ijkPlayer);
        AndroidMediaController controller = new AndroidMediaController(this, false);
        ijkPlayer.setMediaController(controller);
        String url = "http://movie.vods1.cnlive.com/3/vod/2017/0607/3_5d21bed962f44c8eac068942745187ef/ff8080815bf6b453015c83457e311a95_1500.m3u8";
        ijkPlayer.setVideoURI(Uri.parse(url));
        ijkPlayer.start();

    }
}


方式三:Ijkplayer

依赖

compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
布局

  

主页面

package com.example.ijkplayer2;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.dou361.ijkplayer.widget.PlayStateParams;
import com.dou361.ijkplayer.widget.PlayerView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         /*View rootView = getLayoutInflater().from(this).inflate(R.layout.simple_player_view_player, null);
        setContentView(rootView);*/
        new PlayerView(this)
                .setTitle("什么")
                .setScaleType(PlayStateParams.fitparent)
                .hideMenu(true)
                .forbidTouch(false)
                .setPlaySource("http://movie.vods1.cnlive.com/3/vod/2017/0607/3_5d21bed962f44c8eac068942745187ef/ff8080815bf6b453015c83457e311a95_1500.m3u8")
                .startPlay();
    }
}





你可能感兴趣的:(Android_播放视频的多种方式 Ijkplayer 与 jiecao)