├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── GIF ├── j1.gif └── j2.gif ├── README.md ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── videolist │ │ └── yyl │ │ ├── MainActivity.java │ │ ├── adapter │ │ ├── BaseAdapter.java │ │ ├── BaseVideoAdapter.java │ │ └── BaseViewHolder.java │ │ ├── dao │ │ ├── VideoItemData.java │ │ └── VideoListData.java │ │ ├── ui │ │ ├── DemoActivity.java │ │ ├── ListVideoActivity.java │ │ ├── MiniVideoActivity.java │ │ ├── OthereActivity.java │ │ ├── RTSPActivity.java │ │ └── ViewPageListActivity.java │ │ ├── utils │ │ └── DialogUtils.java │ │ └── view │ │ ├── MediaControllerFull.java │ │ └── VideoAdapter.java │ └── res │ ├── anim │ ├── activity_close.xml │ ├── activity_open.xml │ ├── context.xml │ ├── fade_in.xml │ ├── fade_out.xml │ ├── flash.xml │ ├── image_button_anim.xml │ ├── image_button_anim_right.xml │ ├── image_button_anim_translate.xml │ ├── image_button_anim_translate_close.xml │ ├── in_from_down.xml │ ├── in_from_fade.xml │ ├── in_from_left.xml │ ├── in_from_right.xml │ ├── in_from_up.xml │ ├── out_from_down.xml │ ├── out_from_fade.xml │ ├── out_from_left.xml │ ├── out_from_right.xml │ ├── out_from_up.xml │ ├── push_bottom_in.xml │ ├── push_bottom_out.xml │ └── record_focus.xml │ ├── drawable │ ├── mediacontroller_button.xml │ ├── mediacontroller_change.png │ ├── mediacontroller_img_loading.png │ ├── mediacontroller_small_pause.png │ ├── mediacontroller_small_play.png │ ├── mediacontroller_speed.xml │ ├── mediacontroller_speed_last.png │ ├── mediacontroller_speed_next.png │ ├── play_control_scrubber.9.png │ ├── play_control_scrubber2.9.png │ ├── scrubber_primary_holo.9.png │ ├── scrubber_progress_horizontal_holo_dark.xml │ ├── scrubber_secondary_holo.9.png │ ├── seek_thumb.png │ ├── seekbar_horizontal.xml │ └── video_progressbar_drawable.xml │ ├── layout │ ├── activity_demo.xml │ ├── activity_list_video.xml │ ├── activity_main.xml │ ├── activity_mini_video.xml │ ├── activity_othere.xml │ ├── activity_rtsp.xml │ ├── activity_view_page_list.xml │ ├── item_video.xml │ ├── video_view_controller_full.xml │ └── videoview_vlc_list.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ ├── course_player_play.png │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── raw │ └── video_list.json │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ijkplayer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── yyl │ │ └── ijkplayer │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── yyl │ │ │ └── ijkplayer │ │ │ └── VideoView.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── yyl │ └── ijkplayer │ └── ExampleUnitTest.java ├── settings.gradle └── vlcplayer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── yyl │ └── videolist │ ├── FrameLayoutScale.java │ ├── MyVideoView.java │ ├── demo │ ├── VBuffing.java │ └── VideoControllerDemo.java │ ├── listeners │ ├── FullScreenControl.java │ ├── MediaPlayerChangeState.java │ ├── VideoSizeChange.java │ ├── VideoViewControllerListeners.java │ ├── VideoViewDetachedEvent.java │ ├── VideoViewListeners.java │ └── VideoViewTouchListeners.java │ ├── utils │ ├── LogUtils.java │ ├── NetworkUtils.java │ ├── StringUtils.java │ └── V.java │ └── video │ ├── MediaControllerBuffing.java │ ├── MediaControllerSmall.java │ ├── MediaControllerTouch.java │ ├── MySensorListener.java │ ├── VlcMediaController.java │ ├── VlcMediaControllerBase.java │ ├── VlcMediaView.java │ └── VlcVideoViewImpl.java └── res ├── anim ├── in_from_down.xml ├── in_from_fade.xml ├── in_from_up.xml ├── out_from_down.xml ├── out_from_fade.xml └── out_from_up.xml ├── drawable-xhdpi ├── mediacontroller_change.png ├── mediacontroller_small_pause.png ├── mediacontroller_small_play.png ├── mediacontroller_speed_last.png ├── mediacontroller_speed_next.png ├── play_control_scrubber.9.png ├── scrubber_primary_holo.9.png └── scrubber_secondary_holo.9.png ├── drawable ├── mediacontroller_button.xml ├── mediacontroller_speed.xml └── scrubber_progress_horizontal_holo_dark.xml ├── layout ├── video_list_controller.xml ├── video_view_controller_small.xml └── video_view_controller_widget.xml └── values ├── colors.xml ├── strings.xml └── styles.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /GIF/j1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/GIF/j1.gif -------------------------------------------------------------------------------- /GIF/j2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/GIF/j2.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## VlcPlayer 2 | VlcPlayer实现了在列表控件(RecyclerView)中加载并播放视频, 3 | 4 | 非入侵adapter的写法 5 | 6 | #效果预览 7 | ![image](https://github.com/mengzhidaren/VlcPlayer/blob/master/GIF/j1.gif) 8 | ![image](https://github.com/mengzhidaren/VlcPlayer/blob/master/GIF/j2.gif) 9 | #基本用法 10 | 在xml布局中加入以下代码 11 | ``` 12 | 15 | 然后设置视频路径地址,和活动范围 16 | recyclerView最后调用onClickViewPlay()方法开始播放视频 17 | vlcVideoView.onAttached(activity); 18 | vlcVideoView.onAttached(recyclerView); 19 | vlcVideoView.onClickViewPlay(v, videoItemData.getMp4_url()); 20 | //全屏返回 21 | if (vlcVideoView.onBackPressed(this)) return; 22 | 详细请查看代码 23 | ``` 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.butterKnifeVersion='8.8.1' 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.2" 6 | defaultConfig { 7 | applicationId "com.videolist.yyl" 8 | minSdkVersion 15 9 | targetSdkVersion 26 10 | versionCode 2 11 | versionName "2.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:appcompat-v7:26.1.0' 23 | compile 'com.android.support:recyclerview-v7:26.1.0' 24 | compile project(':vlcplayer') 25 | compile 'com.google.code.gson:gson:2.6.2' 26 | compile 'com.github.bumptech.glide:glide:3.7.0' 27 | compile 'com.android.support:support-v4:26.1.0' 28 | compile "com.jakewharton:butterknife:$rootProject.butterKnifeVersion" 29 | compile 'com.android.support:recyclerview-v7:26.1.0' 30 | compile 'com.afollestad.material-dialogs:core:0.8.5.9' 31 | } 32 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\eclipse\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 41 | 45 | 49 | 53 | 57 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | 9 | import com.videolist.yyl.ui.DemoActivity; 10 | import com.videolist.yyl.ui.ListVideoActivity; 11 | import com.videolist.yyl.ui.MiniVideoActivity; 12 | import com.videolist.yyl.ui.OthereActivity; 13 | import com.videolist.yyl.ui.RTSPActivity; 14 | import com.videolist.yyl.ui.ViewPageListActivity; 15 | import com.yyl.videolist.utils.LogUtils; 16 | 17 | import org.videolan.vlc.util.VLCInstance; 18 | 19 | /** 20 | * 市场 上的列表播放器 好像只有这 5 种写法了 21 | * 欢迎补充 22 | */ 23 | public class MainActivity extends AppCompatActivity { 24 | 25 | 26 | @Override 27 | protected void onCreate(@Nullable Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | if (VLCInstance.testCompatibleCPU(this)) { 31 | LogUtils.i("cup ok"); 32 | } else { 33 | LogUtils.i("不支持 什么鬼cpu"); 34 | } 35 | } 36 | 37 | public void demo(View view) { 38 | startActivity(new Intent(this, DemoActivity.class)); 39 | } 40 | 41 | public void rtsp(View view) { 42 | startActivity(new Intent(this, RTSPActivity.class)); 43 | } 44 | 45 | /** 46 | * 常规写法1 47 | * ----切换根布局更换父容器 48 | */ 49 | public void listVideo1(View view) { 50 | //太多了懒的写 51 | } 52 | 53 | /** 54 | * 常规写法2 55 | *

推荐

56 | * 悬浮无入侵 57 | */ 58 | public void listVideo2(View view) {//悬浮播放 59 | startActivity(new Intent(this, ListVideoActivity.class)); 60 | } 61 | 62 | /** 63 | * 常规写法3 64 | * 切换activity 65 | */ 66 | public void listVideo3(View view) { 67 | //太多了懒的写 68 | } 69 | 70 | /** 71 | * 常规写法4 72 | * 旋转rotation 写法 73 | */ 74 | public void listVideo4(View view) { 75 | 76 | } 77 | 78 | /** 79 | * 常规写法5 80 | * 悬浮server 写法和vlc-android 官方一样的实现 感觉不实用 81 | */ 82 | public void listVideo5(View view) { 83 | 84 | } 85 | 86 | 87 | public void viewpage(View view) { 88 | startActivity(new Intent(this, ViewPageListActivity.class)); 89 | } 90 | 91 | public void miniVideo(View view) { 92 | startActivity(new Intent(this, MiniVideoActivity.class)); 93 | } 94 | 95 | public void othere(View view) { 96 | startActivity(new Intent(this, OthereActivity.class)); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/adapter/BaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by yuyunlong on 2016/6/23/023. 13 | */ 14 | public abstract class BaseAdapter extends 15 | RecyclerView.Adapter { 16 | 17 | protected final ArrayList mData = new ArrayList<>(); 18 | 19 | 20 | public boolean isEmpty() { 21 | return mData.size() == 0; 22 | } 23 | 24 | public void addAllItemNotify(ArrayList list) { 25 | mData.addAll(list); 26 | notifyDataSetChanged(); 27 | } 28 | 29 | public void addAllItemNotify(List list) { 30 | mData.addAll(list); 31 | notifyDataSetChanged(); 32 | } 33 | 34 | public void setDataItem(List list) { 35 | mData.clear(); 36 | mData.addAll(list); 37 | notifyDataSetChanged(); 38 | } 39 | 40 | public void addFirst(T t) { 41 | mData.add(0, t); 42 | } 43 | 44 | public void addLast(T t) { 45 | mData.add(mData.size(), t); 46 | } 47 | 48 | 49 | public void addItemList(List data) { 50 | mData.addAll(mData.size(), data); 51 | } 52 | 53 | public void clearAllItem() { 54 | mData.clear(); 55 | } 56 | 57 | @Override 58 | public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 59 | View view = LayoutInflater.from(parent.getContext()).inflate( 60 | getLayoutId(viewType), parent, false); 61 | return getHolder(view, viewType); 62 | } 63 | 64 | @Override 65 | public void onBindViewHolder(BaseViewHolder holder, int position) { 66 | holder.setData(position); 67 | } 68 | 69 | @Override 70 | public int getItemCount() { 71 | return getOtherItemViewCount(); 72 | } 73 | 74 | @Override 75 | public int getItemViewType(int position) { 76 | return getOtherItemViewType(position); 77 | } 78 | 79 | protected int getOtherItemViewCount() { 80 | return mData.size(); 81 | } 82 | 83 | protected int getOtherItemViewType(int position) { 84 | return 0; 85 | } 86 | 87 | protected abstract int getLayoutId(int viewType); 88 | 89 | protected abstract BaseViewHolder getHolder(View itemView, int viewType); 90 | 91 | public void onDestroy() { 92 | 93 | } 94 | 95 | @Override 96 | public void onViewRecycled(BaseViewHolder holder) { 97 | holder.onRecycler(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/adapter/BaseVideoAdapter.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.adapter; 2 | 3 | import android.support.v7.widget.LinearLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | 6 | import com.yyl.videolist.utils.LogUtils; 7 | import com.yyl.videolist.utils.NetworkUtils; 8 | 9 | import java.util.ArrayList; 10 | 11 | /** 12 | * Created by yuyunlong on 2016/8/9/009. 13 | */ 14 | public abstract class BaseVideoAdapter extends BaseAdapter implements BaseViewHolder.VideoViewDetachedEvent { 15 | 16 | private ArrayList holderList = new ArrayList<>(); 17 | 18 | @Override 19 | public void onAttachedToRecyclerView(RecyclerView recyclerView) { 20 | super.onAttachedToRecyclerView(recyclerView); 21 | holderList.clear(); 22 | BaseViewHolder.addEvent(this); 23 | recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { 24 | @Override 25 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 26 | if (newState == RecyclerView.SCROLL_STATE_IDLE && NetworkUtils.isWifiConnected(recyclerView.getContext())) {//自动播放视频代码 27 | LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); 28 | int first = layoutManager.findFirstCompletelyVisibleItemPosition(); 29 | int last = layoutManager.findLastCompletelyVisibleItemPosition(); 30 | if (first == -1 || last == -1) {//没一个全显示 31 | return; 32 | } 33 | for (BaseViewHolder holder : holderList) { 34 | int adapterPosition = holder.getAdapterPosition(); 35 | LogUtils.i("first=" + first + " last=" + last + " adapterPosition=" + adapterPosition + " isVideoType()=" + holder.isVideoType()); 36 | if (first == adapterPosition || adapterPosition == last) {//在view全部可见的item上 37 | if (holder.isVideoType()) { 38 | if (!holder.isPlayVideo()) { 39 | LogUtils.i("startPlayVideo =" + adapterPosition); 40 | holder.startPlayVideo(); 41 | return; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | } 48 | }); 49 | 50 | } 51 | 52 | @Override 53 | public void detachedEvent() { 54 | for (BaseViewHolder holder : holderList) { 55 | if (holder.isPlayVideo()) { 56 | holder.onViewDetachedFromWindow(); 57 | holder.onViewAttachedToWindow(); 58 | } 59 | } 60 | } 61 | 62 | @Override 63 | public void onDetachedFromRecyclerView(RecyclerView recyclerView) { 64 | super.onDetachedFromRecyclerView(recyclerView); 65 | BaseViewHolder.removeEvent(this); 66 | holderList.clear(); 67 | } 68 | 69 | 70 | @Override 71 | public void onViewAttachedToWindow(BaseViewHolder holder) { 72 | super.onViewAttachedToWindow(holder); 73 | holder.onViewAttachedToWindow(); 74 | holderList.add(holder); 75 | } 76 | 77 | @Override 78 | public void onViewDetachedFromWindow(BaseViewHolder holder) { 79 | super.onViewDetachedFromWindow(holder); 80 | holder.onViewDetachedFromWindow(); 81 | holderList.remove(holder); 82 | } 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/adapter/BaseViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | 6 | import java.util.ArrayList; 7 | 8 | /** 9 | * Created by yuyunlong on 2016/6/17/017. 10 | */ 11 | public abstract class BaseViewHolder extends RecyclerView.ViewHolder { 12 | private static final ArrayList videoListDetache = new ArrayList(); 13 | 14 | public interface VideoViewDetachedEvent { 15 | void detachedEvent(); 16 | } 17 | 18 | public static void addEvent(VideoViewDetachedEvent event) { 19 | if (!videoListDetache.contains(event)) 20 | videoListDetache.add(event); 21 | } 22 | 23 | public static void removeEvent(VideoViewDetachedEvent event) { 24 | if (videoListDetache.contains(event)) 25 | videoListDetache.remove(event); 26 | } 27 | 28 | public static void detachedWindow() { 29 | for (VideoViewDetachedEvent detache : videoListDetache) { 30 | detache.detachedEvent(); 31 | } 32 | } 33 | 34 | public BaseViewHolder(View itemView) { 35 | super(itemView); 36 | } 37 | 38 | 39 | public void setData(int position) { 40 | itemView.setOnClickListener(new ItemsOnClick(position)); 41 | } 42 | 43 | 44 | public void setData(int positionH, int positionBody) { 45 | 46 | } 47 | 48 | public void onRecycler() { 49 | } 50 | 51 | public void setOnClick(View v, int position) { 52 | 53 | } 54 | 55 | private class ItemsOnClick implements View.OnClickListener { 56 | final int position; 57 | 58 | public ItemsOnClick(int position) { 59 | this.position = position; 60 | } 61 | 62 | @Override 63 | public void onClick(View v) { 64 | setOnClick(v, position); 65 | } 66 | } 67 | 68 | public void onViewAttachedToWindow() { 69 | } 70 | 71 | public boolean isVideoType() { 72 | return false; 73 | } 74 | 75 | 76 | public void onViewDetachedFromWindow() { 77 | } 78 | 79 | public boolean isPlayVideo() { 80 | return false; 81 | } 82 | 83 | public void startPlayVideo() { 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/dao/VideoItemData.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.dao; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Author wangchenchen 7 | * Description video model 8 | */ 9 | public class VideoItemData implements Serializable { 10 | int type; 11 | String cover; 12 | int playCount; 13 | String title; 14 | String mp4_url; 15 | String ptime; 16 | String vid; 17 | int length; 18 | String videosource; 19 | 20 | public int getType() { 21 | return type; 22 | } 23 | 24 | public void setType(int type) { 25 | this.type = type; 26 | } 27 | 28 | public String getCover() { 29 | return cover; 30 | } 31 | 32 | public void setCover(String cover) { 33 | this.cover = cover; 34 | } 35 | 36 | public int getPlayCount() { 37 | return playCount; 38 | } 39 | 40 | public void setPlayCount(int playCount) { 41 | this.playCount = playCount; 42 | } 43 | 44 | public String getTitle() { 45 | return title; 46 | } 47 | 48 | public void setTitle(String title) { 49 | this.title = title; 50 | } 51 | 52 | public String getMp4_url() { 53 | return mp4_url; 54 | } 55 | 56 | public void setMp4_url(String mp4_url) { 57 | this.mp4_url = mp4_url; 58 | } 59 | 60 | public String getPtime() { 61 | return ptime; 62 | } 63 | 64 | public void setPtime(String ptime) { 65 | this.ptime = ptime; 66 | } 67 | 68 | public String getVid() { 69 | return vid; 70 | } 71 | 72 | public void setVid(String vid) { 73 | this.vid = vid; 74 | } 75 | 76 | public int getLength() { 77 | return length; 78 | } 79 | 80 | public void setLength(int length) { 81 | this.length = length; 82 | } 83 | 84 | public String getVideosource() { 85 | return videosource; 86 | } 87 | 88 | public void setVideosource(String videosource) { 89 | this.videosource = videosource; 90 | } 91 | 92 | boolean isPlaying; 93 | 94 | public boolean isPlaying() { 95 | return isPlaying; 96 | } 97 | 98 | public void setPlaying(boolean playing) { 99 | isPlaying = playing; 100 | } 101 | 102 | int currentPositon; 103 | 104 | public int getCurrentPositon() { 105 | return currentPositon; 106 | } 107 | 108 | public void setCurrentPositon(int currentPositon) { 109 | this.currentPositon = currentPositon; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/dao/VideoListData.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.dao; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * Author wangchenchen 8 | * Description 9 | */ 10 | public class VideoListData implements Serializable { 11 | 12 | private List list; 13 | 14 | public List getList() { 15 | return list; 16 | } 17 | 18 | public void setList(List list) { 19 | this.list = list; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/ui/DemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.ui; 2 | 3 | import android.content.pm.ActivityInfo; 4 | import android.content.res.Configuration; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | 8 | import com.videolist.yyl.R; 9 | import com.yyl.videolist.utils.V; 10 | import com.yyl.videolist.video.VlcMediaView; 11 | 12 | public class DemoActivity extends AppCompatActivity { 13 | VlcMediaView vlcVideoView; 14 | String path = "http://img1.peiyinxiu.com/2014121211339c64b7fb09742e2c.mp4"; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_demo); 20 | vlcVideoView = V.findV(this, R.id.demo_video); 21 | vlcVideoView.onAttached(this); 22 | vlcVideoView.playVideo(path); 23 | getSupportActionBar().setTitle("Demo VideoPlayer"); 24 | } 25 | @Override 26 | public void onConfigurationChanged(Configuration newConfig) { 27 | super.onConfigurationChanged(newConfig); 28 | if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_USER) { 29 | getSupportActionBar().hide(); 30 | } else { 31 | getSupportActionBar().show(); 32 | } 33 | } 34 | @Override 35 | public void onBackPressed() { 36 | if (vlcVideoView.onBackPressed(this)) return; 37 | super.onBackPressed(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/ui/ListVideoActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.ui; 2 | 3 | import android.content.Context; 4 | import android.content.pm.ActivityInfo; 5 | import android.content.res.Configuration; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.support.v7.widget.RecyclerView; 9 | 10 | import com.google.gson.Gson; 11 | import com.videolist.yyl.R; 12 | import com.videolist.yyl.dao.VideoListData; 13 | import com.videolist.yyl.view.VideoAdapter; 14 | import com.yyl.videolist.video.VlcMediaView; 15 | 16 | import java.io.BufferedReader; 17 | import java.io.InputStreamReader; 18 | 19 | public class ListVideoActivity extends AppCompatActivity { 20 | 21 | VideoAdapter videoAdapter; 22 | RecyclerView recyclerView; 23 | VlcMediaView vlcVideoView; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_list_video); 29 | recyclerView = ((RecyclerView) findViewById(R.id.videoList)); 30 | vlcVideoView = ((VlcMediaView) findViewById(R.id.vlc_videoView)); 31 | videoAdapter = new VideoAdapter(vlcVideoView); 32 | recyclerView.setAdapter(videoAdapter); 33 | 34 | 35 | vlcVideoView.onAttached(this); 36 | vlcVideoView.onAttached(recyclerView); 37 | initData(); 38 | getSupportActionBar().setTitle("recycleView列表视频悬浮播放 无入侵写法"); 39 | } 40 | 41 | @Override 42 | public void onConfigurationChanged(Configuration newConfig) { 43 | super.onConfigurationChanged(newConfig); 44 | if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_USER) { 45 | getSupportActionBar().hide(); 46 | } else { 47 | getSupportActionBar().show(); 48 | } 49 | } 50 | 51 | @Override 52 | public void onBackPressed() { 53 | if (vlcVideoView.onBackPressed(this)) return; 54 | super.onBackPressed(); 55 | } 56 | 57 | private void initData() { 58 | String data = readTextFileFromRawResourceId(this, R.raw.video_list); 59 | VideoListData data1 = new Gson().fromJson(data, VideoListData.class); 60 | videoAdapter.refresh(data1.getList()); 61 | } 62 | 63 | public String readTextFileFromRawResourceId(Context context, int resourceId) { 64 | StringBuilder builder = new StringBuilder(); 65 | 66 | BufferedReader reader = new BufferedReader(new InputStreamReader(context.getResources().openRawResource( 67 | resourceId))); 68 | 69 | try { 70 | for (String line = reader.readLine(); line != null; line = reader.readLine()) { 71 | builder.append(line).append("\n"); 72 | } 73 | } catch (Exception e) { 74 | throw new RuntimeException(e); 75 | } 76 | 77 | return builder.toString(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/ui/MiniVideoActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.ui; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.videolist.yyl.R; 7 | 8 | public class MiniVideoActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_mini_video); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/ui/OthereActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.ui; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.videolist.yyl.R; 7 | 8 | public class OthereActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_othere); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/ui/RTSPActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.ui; 2 | 3 | import android.app.ProgressDialog; 4 | import android.net.Uri; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.util.Log; 8 | import android.view.View; 9 | import android.widget.EditText; 10 | 11 | import com.videolist.yyl.R; 12 | import com.yyl.videolist.MyVideoView; 13 | import com.yyl.videolist.utils.V; 14 | 15 | import org.videolan.libvlc.LibVLC; 16 | import org.videolan.libvlc.Media; 17 | import org.videolan.vlc.listener.MediaListenerEvent; 18 | import org.videolan.vlc.util.VLCOptions; 19 | 20 | import java.util.ArrayList; 21 | 22 | /** 23 | * 电视直播 24 | * 请至官方网站查看更多设置 25 | * https://wiki.videolan.org/VLC_command-line_help/ 26 | */ 27 | public class RTSPActivity extends AppCompatActivity implements MediaListenerEvent { 28 | MyVideoView videoView; 29 | String path1 = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";//苹果的m3u8 30 | String path2 = "rtmp://live.hkstv.hk.lxdns.com/live/hks";// h264的地址 31 | String path3 = "rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp";//h263地址 32 | 33 | ProgressDialog progressDialog; 34 | EditText editText; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_rtsp); 40 | editText = V.findV(this, R.id.url_test); 41 | progressDialog = new ProgressDialog(this); 42 | videoView = V.findV(this, R.id.rtsp_video); 43 | videoView.setMediaListenerEvent(this); 44 | videoView.startPlay(path3); 45 | editText.setText(path2); 46 | getSupportActionBar().setTitle("RTSP,电视直播,m3u8"); 47 | } 48 | 49 | @Override 50 | protected void onStop() { 51 | super.onStop(); 52 | videoView.onStop(); 53 | } 54 | 55 | public void test_start(View view) { 56 | 57 | videoView.startPlay(editText.getText().toString()); 58 | } 59 | 60 | /** 61 | *

尝试秒开网络流但是秒开后马上就卡那几秒 62 | *

有用的上的自己慢慢调吧 63 | * 推荐硬解会好点 手机烂的就算了 64 | */ 65 | public void test2() { 66 | // videoView.onStop(); 67 | ArrayList libOptions = VLCOptions.getLibOptions(getApplicationContext()); 68 | // libOptions.add("--rtsp-tcp"); 69 | libOptions.add("--rtsp-http"); 70 | libOptions.add("--rtsp-frame-buffer-size=1024");// --rtsp-frame-buffer-size= 71 | //libOptions.add("--rtsp-timeout=1"); 72 | libOptions.add("--ipv4-timeout=5"); 73 | libOptions.add("--network-caching=500"); 74 | libOptions.add("--androidwindow-chroma"); 75 | libOptions.add("RV16"); 76 | LibVLC libVLC = new LibVLC(getApplicationContext(), libOptions); 77 | // videoView.setMediaPlayer(libVLC); 78 | 79 | final Media media = new Media(libVLC, Uri.parse(path2)); 80 | media.setHWDecoderEnabled(true, true); 81 | media.parseAsync(Media.Parse.FetchNetwork, 10 * 1000); 82 | media.addOption(":file-caching=500"); 83 | media.addOption(":network-caching=500"); 84 | videoView.setMedia(media); 85 | videoView.startPlay(path2); 86 | 87 | } 88 | 89 | long time; 90 | 91 | @Override 92 | public void eventBuffing(int event, float buffing) { 93 | 94 | } 95 | 96 | @Override 97 | public void eventPlayInit(boolean openingVideo) { 98 | if (!openingVideo) { 99 | time = System.currentTimeMillis(); 100 | } else { 101 | long useTime = System.currentTimeMillis() - time; 102 | Log.i("yyl", "打开地址时间=" + useTime); 103 | } 104 | if (openingVideo) 105 | progressDialog.show(); 106 | } 107 | 108 | 109 | @Override 110 | public void eventStop(boolean isPlayError) { 111 | progressDialog.hide(); 112 | } 113 | 114 | @Override 115 | public void eventError(int error, boolean show) { 116 | progressDialog.hide(); 117 | } 118 | 119 | @Override 120 | public void eventPlay(boolean isPlaying) { 121 | if (isPlaying) { 122 | long useTime = System.currentTimeMillis() - time; 123 | Log.i("yyl", "延迟时间=" + useTime); 124 | progressDialog.hide(); 125 | } 126 | } 127 | 128 | 129 | } 130 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/ui/ViewPageListActivity.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.ui; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.videolist.yyl.R; 7 | 8 | public class ViewPageListActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_view_page_list); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/utils/DialogUtils.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.utils; 2 | 3 | import android.content.Context; 4 | 5 | import com.afollestad.materialdialogs.MaterialDialog; 6 | 7 | /** 8 | * Created by Administrator on 2016/1/26/026. 9 | */ 10 | public class DialogUtils { 11 | 12 | 13 | public static MaterialDialog showDialog(Context context, String title, String message, MaterialDialog.SingleButtonCallback singleButtonCallback) { 14 | return new MaterialDialog.Builder(context) 15 | .title(title) 16 | .content(message) 17 | .positiveText("确定").negativeText("取消").onPositive(singleButtonCallback).onNegative(singleButtonCallback).show(); 18 | } 19 | 20 | public static MaterialDialog show3GDialog(Context context, MaterialDialog.SingleButtonCallback singleButtonCallback) { 21 | return showDialog(context, "提示", "当前是3G网络是否继续播放", singleButtonCallback); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/view/MediaControllerFull.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.view; 2 | 3 | import android.view.View; 4 | import android.view.animation.Animation; 5 | import android.view.animation.AnimationUtils; 6 | import android.widget.ImageButton; 7 | import android.widget.LinearLayout; 8 | import android.widget.SeekBar; 9 | import android.widget.TextView; 10 | 11 | import com.videolist.yyl.R; 12 | import com.yyl.videolist.listeners.FullScreenControl; 13 | import com.yyl.videolist.listeners.VideoViewControllerListeners; 14 | import com.yyl.videolist.utils.LogUtils; 15 | import com.yyl.videolist.utils.StringUtils; 16 | import com.yyl.videolist.video.MySensorListener; 17 | 18 | import org.videolan.vlc.listener.MediaPlayerControl; 19 | 20 | import butterknife.BindView; 21 | import butterknife.ButterKnife; 22 | import butterknife.OnClick; 23 | 24 | 25 | /** 26 | * Created by yyl on 2016/2/16/016. 27 | *

28 | * 全屏播放器 底布局 29 | */ 30 | public class MediaControllerFull implements VideoViewControllerListeners { 31 | 32 | public MediaPlayerControl mPlayer; 33 | 34 | @BindView(R.id.mediacontroller_back) 35 | ImageButton mediacontrollerBack; 36 | @BindView(R.id.mediacontroller_file_name) 37 | TextView mediacontrollerFileName; 38 | @BindView(R.id.mediacontroller_projection) 39 | ImageButton mediacontrollerProjection; 40 | @BindView(R.id.mediacontroller_lock) 41 | ImageButton mediacontrollerLock; 42 | @BindView(R.id.mediacontroller_share) 43 | ImageButton mediacontrollerShare; 44 | 45 | @BindView(R.id.mediacontroller_time_current) 46 | TextView mCurrentTime; 47 | 48 | @BindView(R.id.mediacontroller_playmode) 49 | ImageButton loopButton; 50 | @BindView(R.id.mediacontroller_last) 51 | ImageButton mediacontrollerLast; 52 | @BindView(R.id.mediacontroller_play_pause) 53 | ImageButton mPauseButton; 54 | @BindView(R.id.mediacontroller_next) 55 | ImageButton mediacontrollerNext; 56 | @BindView(R.id.mediacontroller_mirror) 57 | TextView mediacontrollerMirror; 58 | 59 | @BindView(R.id.mediacontroller_speed_change) 60 | TextView mediacontroller_speed_change; 61 | 62 | @BindView(R.id.mediacontroller_seekbar) 63 | SeekBar mProgress; 64 | 65 | 66 | @BindView(R.id.mediacontroller_tag) 67 | LinearLayout mediacontrollerTag; 68 | 69 | @BindView(R.id.mediacontroller_down_layout) 70 | View down_layout; 71 | 72 | @BindView(R.id.mediacontroller_up_layout) 73 | View upLayout; 74 | 75 | 76 | @BindView(R.id.mediacontroller_conter_bg) 77 | View conterLayout; 78 | private FullScreenControl fullScreenControl; 79 | 80 | 81 | private long mDuration; 82 | private boolean mDragging; 83 | private boolean mInstantSeeking = false; 84 | 85 | public void setLoopState(boolean loopState) { 86 | 87 | } 88 | 89 | public void setFileName(String name) { 90 | mediacontrollerFileName.setText(name); 91 | } 92 | 93 | public void onProgressUpdate(long current, long duration) { 94 | setProgress(); 95 | } 96 | 97 | @Override 98 | public boolean onSingleTapConfirmed() { 99 | return false; 100 | } 101 | 102 | @Override 103 | public void onDoubleTap() { 104 | 105 | } 106 | 107 | 108 | private SeekBar.OnSeekBarChangeListener mSeekListener = new SeekBar.OnSeekBarChangeListener() { 109 | public void onStartTrackingTouch(SeekBar bar) { 110 | mDragging = true; 111 | } 112 | 113 | public void onProgressChanged(SeekBar bar, int progress, boolean fromuser) { 114 | if (!fromuser) 115 | return; 116 | long newposition = (mDuration * progress) / 1000; 117 | String time = StringUtils.generateTime(newposition); 118 | if (mInstantSeeking) 119 | mPlayer.seekTo((int)newposition); 120 | if (mCurrentTime != null) 121 | mCurrentTime.setText(time); 122 | } 123 | 124 | public void onStopTrackingTouch(SeekBar bar) { 125 | if (!mInstantSeeking) 126 | mPlayer.seekTo((int)(mDuration * bar.getProgress()) / 1000); 127 | mDragging = false; 128 | } 129 | }; 130 | 131 | public boolean isDragging() { 132 | return mDragging; 133 | } 134 | 135 | 136 | public MediaControllerFull(View layoutRootView, MediaPlayerControl player, FullScreenControl fullScreenControl) { 137 | ButterKnife.bind(this, layoutRootView); 138 | this.mPlayer = player; 139 | this.fullScreenControl = fullScreenControl; 140 | initView(); 141 | } 142 | 143 | private void initView() { 144 | mediacontrollerLock.setSelected(MySensorListener.isLock()); 145 | mProgress.setPadding(0, 0, 0, 0); 146 | mProgress.setOnSeekBarChangeListener(mSeekListener); 147 | mProgress.setMax(1000); 148 | mProgress.setThumbOffset(0); 149 | } 150 | 151 | 152 | /** 153 | * Control the action when the seekbar dragged by user 154 | * 155 | * @param seekWhenDragging True the media will seek periodically 156 | */ 157 | public void setInstantSeeking(boolean seekWhenDragging) { 158 | mInstantSeeking = seekWhenDragging; 159 | } 160 | 161 | 162 | private boolean mShowing; 163 | 164 | public void show() { 165 | if (mShowing) { 166 | return; 167 | } 168 | mShowing = true; 169 | startOpenAnimation(); 170 | } 171 | 172 | 173 | @Override 174 | public void show(int time) { 175 | 176 | } 177 | 178 | public void hide() { 179 | if (mShowing) { 180 | mShowing = false; 181 | startHideAnimation(); 182 | } 183 | } 184 | 185 | public void close() { 186 | mShowing = false; 187 | upLayout.setVisibility(View.GONE); 188 | down_layout.setVisibility(View.GONE); 189 | conterLayout.setVisibility(View.GONE); 190 | } 191 | 192 | @Override 193 | public void changeLayoutState(int layoutState) { 194 | 195 | } 196 | 197 | public void startOpenAnimation() { 198 | if (down_layout.getVisibility() != View.VISIBLE) { 199 | down_layout.setVisibility(View.VISIBLE); 200 | } 201 | if (upLayout.getVisibility() != View.VISIBLE) { 202 | upLayout.setVisibility(View.VISIBLE); 203 | } 204 | if (conterLayout.getVisibility() != View.VISIBLE) { 205 | conterLayout.setVisibility(View.VISIBLE); 206 | } 207 | 208 | Animation in_from_fade = AnimationUtils.loadAnimation(down_layout.getContext(), R.anim.in_from_fade); 209 | Animation in_from_down = AnimationUtils.loadAnimation(down_layout.getContext(), R.anim.in_from_down); 210 | Animation in_from_up = AnimationUtils.loadAnimation(down_layout.getContext(), R.anim.in_from_up); 211 | 212 | conterLayout.clearAnimation(); 213 | conterLayout.startAnimation(in_from_fade); 214 | 215 | upLayout.clearAnimation(); 216 | upLayout.startAnimation(in_from_up); 217 | 218 | down_layout.clearAnimation(); 219 | down_layout.startAnimation(in_from_down); 220 | } 221 | 222 | public void startHideAnimation() { 223 | Animation out_from_down = AnimationUtils.loadAnimation(down_layout.getContext(), R.anim.out_from_down); 224 | Animation out_from_up = AnimationUtils.loadAnimation(down_layout.getContext(), R.anim.out_from_up); 225 | Animation out_from_fade = AnimationUtils.loadAnimation(down_layout.getContext(), R.anim.out_from_fade); 226 | 227 | // out_from_fade.setAnimationListener(animationListener); 228 | // out_from_up.setAnimationListener(animationListener); 229 | out_from_down.setAnimationListener(animationListener); 230 | 231 | conterLayout.clearAnimation(); 232 | conterLayout.startAnimation(out_from_fade); 233 | 234 | upLayout.clearAnimation(); 235 | upLayout.startAnimation(out_from_up); 236 | 237 | down_layout.clearAnimation(); 238 | down_layout.startAnimation(out_from_down); 239 | } 240 | 241 | public Animation.AnimationListener animationListener = new Animation.AnimationListener() { 242 | @Override 243 | public void onAnimationStart(Animation animation) { 244 | } 245 | 246 | @Override 247 | public void onAnimationEnd(Animation animation) { 248 | down_layout.setVisibility(View.GONE); 249 | upLayout.setVisibility(View.GONE); 250 | conterLayout.setVisibility(View.GONE); 251 | } 252 | 253 | @Override 254 | public void onAnimationRepeat(Animation animation) { 255 | 256 | } 257 | }; 258 | 259 | public boolean isShowing() { 260 | return mShowing; 261 | } 262 | 263 | 264 | private long setProgress() { 265 | if (!mShowing || mDragging) 266 | return 0; 267 | long position = mPlayer.getCurrentPosition(); 268 | long duration = mPlayer.getDuration(); 269 | if (mProgress != null) { 270 | if (duration > 0) { 271 | long pos = 1000L * position / duration; 272 | mProgress.setProgress((int) pos); 273 | } 274 | //int percent = mPlayer.getBufferPercentage(); 275 | //mProgress.setSecondaryProgress(percent * 10); 276 | } 277 | updatePausePlay(); 278 | mDuration = duration; 279 | if (mCurrentTime != null) 280 | mCurrentTime.setText(StringUtils.generateTime(position) + " / " + StringUtils.generateTime(mDuration)); 281 | return position; 282 | } 283 | 284 | 285 | public void setLoop(boolean loop) { 286 | loopButton.setSelected(loop); 287 | } 288 | 289 | public void setEnabled(boolean enabled) { 290 | if (mProgress != null) 291 | mProgress.setEnabled(enabled); 292 | 293 | } 294 | 295 | private void updatePausePlay() { 296 | mPauseButton.setSelected(mPlayer.isPlaying()); 297 | } 298 | 299 | public void hideLastButton() { 300 | mediacontrollerLast.setEnabled(false); 301 | } 302 | 303 | public void showLastButton() { 304 | mediacontrollerLast.setEnabled(true); 305 | } 306 | 307 | public void hideNextButton() { 308 | mediacontrollerNext.setEnabled(false); 309 | } 310 | 311 | public void showNextButton() { 312 | mediacontrollerNext.setEnabled(true); 313 | } 314 | 315 | private void doPauseResume() { 316 | if (mPlayer.isPlaying()) { 317 | mPlayer.pause(); 318 | } else { 319 | mPlayer.start(); 320 | } 321 | updatePausePlay(); 322 | } 323 | 324 | private int speed = 1; 325 | 326 | private void setSpeed() { 327 | String speedText = "1.0X"; 328 | switch (speed) { 329 | case 1: 330 | mPlayer.setPlaybackSpeedMedia(0.25f); 331 | speed = 2; 332 | speedText = "0.2X"; 333 | break; 334 | case 2: 335 | mPlayer.setPlaybackSpeedMedia(0.4f); 336 | speed = 4; 337 | speedText = "0.4X"; 338 | break; 339 | case 4: 340 | mPlayer.setPlaybackSpeedMedia(0.6f); 341 | speed = 6; 342 | speedText = "0.6X"; 343 | break; 344 | case 6: 345 | mPlayer.setPlaybackSpeedMedia(0.8f); 346 | speed = 8; 347 | speedText = "0.8X"; 348 | break; 349 | case 8: 350 | mPlayer.setPlaybackSpeedMedia(1f); 351 | speed = 1; 352 | speedText = "1.0X"; 353 | break; 354 | } 355 | mediacontroller_speed_change.setText(speedText); 356 | } 357 | 358 | 359 | @OnClick({R.id.mediacontroller_speed_change, R.id.mediacontroller_back, R.id.mediacontroller_projection, R.id.mediacontroller_lock, R.id.mediacontroller_share, R.id.mediacontroller_playmode, R.id.mediacontroller_last, R.id.mediacontroller_play_pause, R.id.mediacontroller_next, R.id.mediacontroller_mirror}) 360 | public void onClick(View view) { 361 | LogUtils.i("view.getId()=" + view.getId()); 362 | fullScreenControl.clickEvent(); 363 | switch (view.getId()) { 364 | case R.id.mediacontroller_speed_change: 365 | setSpeed(); 366 | break; 367 | case R.id.mediacontroller_back: 368 | fullScreenClick.back(view); 369 | break; 370 | case R.id.mediacontroller_projection://二维码切屏 371 | fullScreenClick.projection(view); 372 | break; 373 | case R.id.mediacontroller_lock: 374 | MySensorListener.setLock(!MySensorListener.isLock()); 375 | view.setSelected(MySensorListener.isLock()); 376 | break; 377 | case R.id.mediacontroller_playmode: 378 | // boolean singleCyclePlay = !PrefCache.getLoopPlay(view.getContext()); 379 | // PrefCache.saveLoopPlay(view.getContext(), singleCyclePlay); 380 | // mPlayer.setLoop(singleCyclePlay); 381 | // setLoop(singleCyclePlay); 382 | break; 383 | case R.id.mediacontroller_last: 384 | fullScreenClick.last(view); 385 | break; 386 | case R.id.mediacontroller_play_pause: 387 | doPauseResume(); 388 | break; 389 | case R.id.mediacontroller_next: 390 | fullScreenClick.next(view); 391 | break; 392 | case R.id.mediacontroller_mirror: 393 | boolean mirror = !mPlayer.getMirror(); 394 | boolean mirrorState = !view.isSelected(); 395 | mPlayer.setMirror(mirror); 396 | setMirrorState(mirrorState); 397 | break; 398 | case R.id.mediacontroller_share: 399 | fullScreenClick.share(view); 400 | break; 401 | } 402 | } 403 | 404 | 405 | public void setMirrorState(boolean mirror) { 406 | mediacontrollerMirror.setText(mirror ? "已镜面" : "未镜面"); 407 | mediacontrollerMirror.setSelected(mirror); 408 | } 409 | 410 | 411 | public void setMirrorEnable(boolean enable) { 412 | 413 | } 414 | 415 | private FullScreenClick fullScreenClick; 416 | 417 | public void setFullScreenClick(FullScreenClick fullScreenClick) { 418 | this.fullScreenClick = fullScreenClick; 419 | } 420 | 421 | @Override 422 | public void eventBuffing(int event, float buffing) { 423 | 424 | } 425 | 426 | @Override 427 | public void eventPlayInit(boolean opening) { 428 | 429 | } 430 | 431 | @Override 432 | public void eventStop(boolean isPlayError) { 433 | 434 | } 435 | 436 | @Override 437 | public void eventError(int error, boolean show) { 438 | 439 | } 440 | 441 | @Override 442 | public void eventPlay(boolean isPlaying) { 443 | 444 | } 445 | 446 | 447 | 448 | 449 | public interface FullScreenClick { 450 | void share(View view); 451 | 452 | void last(View view); 453 | 454 | void next(View view); 455 | 456 | void back(View view); 457 | 458 | void projection(View view); 459 | 460 | } 461 | } 462 | -------------------------------------------------------------------------------- /demo/src/main/java/com/videolist/yyl/view/VideoAdapter.java: -------------------------------------------------------------------------------- 1 | package com.videolist.yyl.view; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.bumptech.glide.Glide; 11 | import com.videolist.yyl.R; 12 | import com.videolist.yyl.dao.VideoItemData; 13 | import com.yyl.videolist.video.VlcMediaView; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | 19 | /** 20 | * Created by Administrator on 2016/10/17/017. 21 | */ 22 | 23 | public class VideoAdapter extends RecyclerView.Adapter { 24 | 25 | private List list = new ArrayList<>(); 26 | VlcMediaView vlcVideoView; 27 | 28 | public VideoAdapter(VlcMediaView vlcVideoView) { 29 | this.vlcVideoView = vlcVideoView; 30 | } 31 | 32 | @Override 33 | public VideoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 34 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_video, parent, false); 35 | return new VideoViewHolder(view); 36 | } 37 | 38 | @Override 39 | public void onBindViewHolder(VideoViewHolder holder, int position) { 40 | holder.setData(position); 41 | } 42 | 43 | @Override 44 | public int getItemCount() { 45 | return list.size(); 46 | } 47 | 48 | public void refresh(List list) { 49 | this.list.clear(); 50 | this.list.addAll(list); 51 | notifyDataSetChanged(); 52 | } 53 | 54 | public class VideoViewHolder extends RecyclerView.ViewHolder { 55 | TextView title; 56 | ImageView cover; 57 | TextView from; 58 | TextView vlc_type; 59 | 60 | public VideoViewHolder(View itemView) { 61 | super(itemView); 62 | title=itemView.findViewById(R.id.vlc_title); 63 | cover=itemView.findViewById(R.id.cover); 64 | from=itemView.findViewById(R.id.vlc_from); 65 | vlc_type=itemView.findViewById(R.id.vlc_type); 66 | } 67 | 68 | public void setData(final int position) { 69 | final VideoItemData videoItemData = list.get(position); 70 | title.setText(videoItemData.getTitle()); 71 | cover.setOnClickListener(new View.OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | vlcVideoView.onClickViewPlay(v, videoItemData.getMp4_url()); 75 | } 76 | }); 77 | Glide.with(cover.getContext()).load(videoItemData.getCover()).into(cover); 78 | from.setText(videoItemData.getVideosource()); 79 | vlc_type.setText(videoItemData.getType() + "=type"); 80 | } 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /demo/src/main/res/anim/activity_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/activity_open.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/fade_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/fade_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/flash.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 25 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/image_button_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/image_button_anim_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/image_button_anim_translate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/image_button_anim_translate_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/in_from_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/in_from_fade.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/in_from_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/in_from_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/in_from_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/out_from_down.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/out_from_fade.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/out_from_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/out_from_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/out_from_up.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/push_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/push_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/record_focus.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 19 | 25 | 37 | 38 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/mediacontroller_change.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_img_loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/mediacontroller_img_loading.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_small_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/mediacontroller_small_pause.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_small_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/mediacontroller_small_play.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_speed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_speed_last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/mediacontroller_speed_last.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/mediacontroller_speed_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/mediacontroller_speed_next.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/play_control_scrubber.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/play_control_scrubber.9.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/play_control_scrubber2.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/play_control_scrubber2.9.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/scrubber_primary_holo.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/scrubber_primary_holo.9.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/scrubber_progress_horizontal_holo_dark.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 16 | 17 | 20 | 21 | 22 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/scrubber_secondary_holo.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/scrubber_secondary_holo.9.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/seek_thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengzhidaren/VlcPlayer/5c23234ba1b39e37f25447c7472d671469554e68/demo/src/main/res/drawable/seek_thumb.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/seekbar_horizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/video_progressbar_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_list_video.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |