8000 GitHub - charlie-captain/TVideoPlayer: videoplayer base on mediaplayer and surfaceview, gravitational induction and notchcompat
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

charlie-captain/TVideoPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TVideoPlayer

特性

  • 用MediaPlayer + SurfaceView封装,可自定义MediaPlayer

  • 重力感应切换全屏

  • 手势滑动调节播放进度、亮度、声音

  • 采用Glide绑定生命周期方式(无需在Activity/Fragment回调方法)

  • 实时监测网络状态并给予提示

  • 适配各大厂商刘海屏

使用

  • Gradle

    implementation 'com.github.thatnight:tvideoplayer:0.2'
    
  • 基本使用

    AndroidManifest.xml

     <activity android:name=".view.activity.VideoActivity"
                      android:configChanges="orientation|keyboardHidden|screenSize" >
     </activity>
    

    布局中

        <com.thatnight.tvideoplayer.player.TVideoPlayerView android:id="@+id/tvideo_video"
                                                            android:layout_width="match_parent"
                                                            android:layout_height="180dp"
        >
        </com.thatnight.tvideoplayer.player.TVideoPlayerView>
    

    Activity中

    mTVideoPlayer = findViewById(R.id.tvideo_video);
    //创建配置
    TVideoPlayerConfig config = new TVideoPlayerConfig.Builder()
            .autoRotate()    //开启重力感应
            .looping()       //循环播放
            .build();
    //设置VideoPlayer
    mTVideoPlayer
    .bind(this)         //绑定生命周期
    .setTitle(mVideoInfo.getTitle())    //设置标题
    .setCoverUrl(mVideoInfo.getCover()) //设置封面
    .setDataSource(mUrlVideo)           //设置视频链接
    .setConfig(config);                 //设置上面的配置
    
  • Activity后退监听(退出全屏模式)

    @Override
    public void onBackPressed() {
        if (!TVideoPlayerManager.getInstance().onBackPressed()) {
            super.onBackPressed();
        }
    }
    

感谢

Licenses

Copyright 2018 thatnight

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

videoplayer base on mediaplayer and surfaceview, gravitational induction and notchcompat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0