{"id":13832010,"url":"https://github.com/waynell/VideoListPlayer","last_synced_at":"2025-07-09T15:34:23.673Z","repository":{"id":96027192,"uuid":"54194374","full_name":"waynell/VideoListPlayer","owner":"waynell","description":"Play video in ListView or RecyclerView","archived":false,"fork":false,"pushed_at":"2017-01-05T13:07:49.000Z","size":6850,"stargazers_count":1329,"open_issues_count":18,"forks_count":260,"subscribers_count":56,"default_branch":"master","last_synced_at":"2024-11-12T19:51:17.685Z","etag":null,"topics":["listview","recyclerview","video-player"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/waynell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-18T10:49:00.000Z","updated_at":"2024-10-04T08:15:15.000Z","dependencies_parsed_at":"2023-03-12T23:15:20.949Z","dependency_job_id":null,"html_url":"https://github.com/waynell/VideoListPlayer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynell%2FVideoListPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynell%2FVideoListPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynell%2FVideoListPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynell%2FVideoListPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waynell","download_url":"https://codeload.github.com/waynell/VideoListPlayer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225565964,"owners_count":17489290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["listview","recyclerview","video-player"],"created_at":"2024-08-04T10:01:47.522Z","updated_at":"2024-11-20T13:32:22.788Z","avatar_url":"https://github.com/waynell.png","language":"Java","readme":"[![Build Status](https://semaphoreapp.com/api/v1/projects/d4cca506-99be-44d2-b19e-176f36ec8cf1/128505/shields_badge.svg)](https://github.com/waynell/VideoListPlayer) [![](https://jitpack.io/v/waynell/VideoListPlayer.svg)](https://jitpack.io/#waynell/VideoListPlayer)\n\n# VideoListPlayer\nVideoListPlayer实现了在列表控件（ListView, RecyclerView）中加载并播放视频，并支持滑动时自动播放/暂停的功能\n\n利用该项目，可以轻松实现类似Instagram的视频播放功能\n\n**注意：最低支持API 14以上**\n\n#效果预览\n![](./art/preview.gif) ![](./art/Screenshot_20160716.png)\n\n#Changelogs\n\n**v.14**\n\n1. 支持更多类型的scaleType，详见 [Android-ScalableVideoView](https://github.com/yqritc/Android-ScalableVideoView)\n2. 加入 `getCurrentPosition()` 和 `getDuration()` 接口\n\n**v1.3**\n\n1. fix在多类型列表元素中出现视频无法正常播放的bug\n\n**Demo 更新**\n\t\n1. 增加在ListView中播放视频的示例\n2. ListView和RecyclerView中支持多类型view type展示\n\n\n**v1.2**\n\t\n1. fix NPE bugs\n\n**v1.1**\n\n1. 自动播放/停止功能性能优化\n\n2. 视频播放加入声音开关控制，默认播放视频关闭声音，点击视频开启声音\n\n3. fix在4.1.1以下无法播放视频的bug\n\n\n#基本用法\n添加gradle依赖\n\t\n\trepositories {\n\t\tmaven { url \"https://jitpack.io\" }\n\t}\n\t\n\tdependencies {\n\t        compile 'com.github.waynell:VideoListPlayer:1.4'\n\t}\n\n在xml布局中加入以下代码\n\n\t\u003ccom.waynell.videolist.widget.TextureVideoView\n            android:id=\"@+id/video_view\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"300dp\" /\u003e\n            \n然后设置视频路径地址，最后调用start()方法开始播放视频\n\n\tvideoView.setVideoPath(mVideoPath);\n    videoView.start();\n\n视频播放是异步的，可以通过设置MediaPlayerCallback回调监听播放事件\n\n\tview.setMediaPlayerCallback(this);\n\n监听事件如下\n\n    void onPrepared(MediaPlayer mp);\n    void onCompletion(MediaPlayer mp);\n    void onBufferingUpdate(MediaPlayer mp, int percent);\n    void onVideoSizeChanged(MediaPlayer mp, int width, int height);\n\n    boolean onInfo(MediaPlayer mp, int what, int extra);\n    boolean onError(MediaPlayer mp, int what, int extra);\n\n\n#滑动时自动播放/停止的功能\n首先，你必须实现ListItem接口来获取item被激活或取消激活的事件回调\n\t\n    public interface ListItem {\n        \n        // 当前item被激活\n        void setActive(View newActiveView, int newActiveViewPosition);\n        \n        // 当前item被取消\n        void deactivate(View currentView, int position);\n\t}\n\n其次，实现ItemsProvider接口返回当前列表总数和列表中某一位置的ListItem实例\n\t\n    public interface ItemsProvider {\n\n    \tListItem getListItem(int position);\n\n    \tint listItemSize();\n\t}\n\n最后添加以下代码实现可见比的计算，以RecyclerView为例\n\t\n    ItemsProvider itemProvider;\n\n\tListItemsVisibilityCalculator calculator = new SingleListViewItemActiveCalculator(itemProvider,\n    \tnew RecyclerViewItemPositionGetter(layoutManager, mRecyclerView););\n    \n    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {\n            @Override\n            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {\n                mScrollState = newState;\n                if(newState == RecyclerView.SCROLL_STATE_IDLE \u0026\u0026 !mListItems.isEmpty()){\n                    mCalculator.onScrollStateIdle();\n                }\n            }\n\n            @Override\n            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {\n                mCalculator.onScrolled(mScrollState);\n            }\n        });\n        \n# 网络视频的本地缓存\n请参考demo工程的实现\n\n\n#实现原理\n请参见我的博客 [视频在滑动列表中的异步缓存和播放](http://blog.waynell.com/2016/03/21/video-loader/)\n\n\n#Thanks\n[VideoPlayerManager](https://github.com/danylovolokh/VideoPlayerManager)\n滑动自动播放/暂停的功能基于项目优化而来\n","funding_links":[],"categories":["Java","video-player"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaynell%2FVideoListPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaynell%2FVideoListPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaynell%2FVideoListPlayer/lists"}