GiraffePlayer

介绍:

基于ijkplayer封装的视频播放器。

运行效果:

使用说明:

场景1: 只需要全屏播放

直接调用GiraffePlayerActivity.configPlayer(activity).play(url)。

场景2:嵌套在布局中

步骤 1: 把video layout include到布局中

<include
        layout="@layout/giraffe_player"
        android:layout_width="match_parent"
        android:layout_height="210dp"/>

注意:giraffe player默认是 match_parent 的,如果你想指定 height 或者 width 可以在include标签中重写 layout_width 和 layout_width

步骤 2: 创建player对象并调用play

GiraffePlayer player = new GiraffePlayer(activity);
player.play(url);

API:

  • play(url) //play video

  • stop() //stop play

  • pause()

  • start()

  • forward() // forward or back,example: forward(0.1f) forward(-0.1f)

  • getCurrentPosition()

  • setScaleType(GiraffePlayer.SCALETYPE_FITPARENT) //set video scale type

  • toggleAspectRatio() // toggle video scale type

  • seekTo(...) //seek to specify position

  • getDuration() //get video duration

  • onInfo(...) //callback when have some information

  • onError(...) //callback when an error occurred

  • onComplete(...) //callback when the play is over

  • onControlPanelVisibilityChange(...) //callback when control panel visibility change

截图

已下载
0