Ver código fonte

乐播投屏接入修改

czq 2 anos atrás
pai
commit
64abf7f3ad

+ 2 - 0
.idea/misc.xml

@@ -13,6 +13,7 @@
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_ijkplay.xml" value="0.1390625" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_lottie.xml" value="0.1" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_main.xml" value="0.1375" />
+        <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_my_video.xml" value="0.16" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_progress.xml" value="0.22" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_quxian.xml" value="0.13645833333333332" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_sequential_drag.xml" value="0.12092391304347826" />
@@ -26,6 +27,7 @@
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_view.xml" value="0.25" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_web.xml" value="0.1816123188405797" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/demo_activity.xml" value="0.18020833333333333" />
+        <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/item_device.xml" value="0.13020833333333334" />
       </map>
     </option>
   </component>

+ 3 - 2
app/build.gradle

@@ -13,7 +13,7 @@ android {
     buildToolsVersion "30.0.3"
 
     defaultConfig {
-        applicationId "com.bestv.edu"
+        applicationId "com.bestv.app"
         minSdkVersion 21
         targetSdkVersion 30
         versionCode 1
@@ -164,5 +164,6 @@ dependencies {
 
     //完整版引入
     implementation 'com.shuyu:GSYVideoPlayer:8.1.2'
-
+    implementation 'com.blankj:utilcodex:1.31.0'
+    implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.3'
 }

+ 9 - 5
app/src/main/java/com/bestv/edu/App.java

@@ -8,6 +8,8 @@ import android.os.Bundle;
 import android.util.Log;
 
 import com.bestv.edu.dlan.CastManager;
+import com.bestv.edu.dlan.DLNAControlCenter;
+import com.blankj.utilcode.util.DeviceUtils;
 import com.hpplay.sdk.source.api.IBindSdkListener;
 import com.hpplay.sdk.source.api.ILelinkPlayerListener;
 import com.hpplay.sdk.source.api.LelinkSourceSDK;
@@ -42,10 +44,10 @@ public class App extends Application {
 	@Override
 	public void onCreate() {
 		super.onCreate();
-//		initUmengSDK();
+		initUmengSDK();
 		app = this;
-//		JPushInterface.setDebugMode(true);
-//		JPushInterface.init(this);
+		JPushInterface.setDebugMode(true);
+		JPushInterface.init(this);
 //		getSHA1Signature(this);
 		initLebo();
 	}
@@ -56,13 +58,15 @@ public class App extends Application {
 			@Override
 			public void onBindCallback(boolean success) {
 				Log.e("LeBo","初始化:"+success);
-				LelinkSourceSDK.getInstance().setPermissionMode( IAPI.PERMISSION_MODE_CLOUD_LICENSE, "123342");
+				LelinkSourceSDK.getInstance().setPermissionMode( IAPI.PERMISSION_MODE_CLOUD_LICENSE, DeviceUtils.getUniqueDeviceId());
 			}
 		};
+//		DLNAControlCenter.getInstance();
 		LelinkSourceSDK.getInstance()
 				.setBindSdkListener(mBindSdkListener)
 				.setPlayListener(CastManager.getInstance().getLelinkPlayerListener())
-				.setSdkInitInfo(getApplicationContext(),"20268", "30ff4917114c5241eddbef00e5be7f6b")
+				.setSdkInitInfo(this, "17894", "69ce8955094258d339c1b6eadef2ec09")
+//				.setSdkInitInfo(this,"20268", "30ff4917114c5241eddbef00e5be7f6b")
 				.bindSdk();
 	}
 

+ 5 - 110
app/src/main/java/com/bestv/edu/activity/GSXYVideoPlayerActivity.java

@@ -9,6 +9,7 @@ import android.widget.Button;
 
 import androidx.annotation.Nullable;
 
+import com.bestv.edu.dlan.DLNAControlCenter;
 import com.hpplay.sdk.source.api.IBindSdkListener;
 import com.hpplay.sdk.source.api.LelinkSourceSDK;
 import com.hpplay.sdk.source.browse.api.IAPI;
@@ -36,7 +37,6 @@ public class GSXYVideoPlayerActivity extends Activity {
 	private OrientationUtils orientationUtils;
 	private Button btn;
 	private boolean isFirst = false;
-	private ViewGroup mBrowseContainer;
 
 	private String url = "http://v3.cztv.com/cztv/vod/2018/06/28/7c45987529ea410dad7c088ba3b53dac/h264_1500k_mp4.mp4";
 	@Override
@@ -44,118 +44,14 @@ public class GSXYVideoPlayerActivity extends Activity {
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_gsxy_video);
 		init();
-		mBindSdkListener = new IBindSdkListener() {
-			@Override
-			public void onBindCallback(boolean success) {
-				Log.e("LeBo","初始化:"+success);
-			}
-		};
-
-//		LelinkSourceSDK.getInstance().setEasyCastListener(mCastListener);
-		LelinkSourceSDK.getInstance().setBrowseResultListener(browserListener);
 	}
-	private IBindSdkListener mBindSdkListener;
-	void initLebo(){
 
-		LelinkSourceSDK.getInstance().startBrowse();
-//		LelinkSourceSDK.getInstance()
-////				.setBindSdkListener(mBindSdkListener)
-//				//FIXME WARN: 这里替换为您申请的AppID & AppSecret,build.gradle替换为您的应用包名 com.bestv.edu  原com.xunao.effectdemo
-////				.setSdkInitInfo(this, "20268", "30ff4917114c5241eddbef00e5be7f6b")
-//				.easyPush(mBrowseContainer);
 
-	}
-	private IBrowseListener browserListener = new IBrowseListener() {
-
-		@Override
-		public void onBrowse(int resultCode, List<LelinkServiceInfo> list) {
-			Log.e("MyTag","搜索:"+resultCode+"   "+IBrowseListener.BROWSE_SUCCESS);
-		}
-	};
-	private IEasyCastListener mCastListener = new IEasyCastListener() {
-
-		/**
-		 * 如果没有触发此回调,则表示此次未搜索到设备或用户未投屏
-		 * @param lelinkServiceInfo
-		 * @return
-		 */
-		@Override
-		public EasyCastBean onCast(LelinkServiceInfo lelinkServiceInfo) {
-			EasyCastBean bean = new EasyCastBean();
-			bean.url = url; //实际需要投屏的url
-			return bean;
-		}
-
-		/**
-		 * 如果投屏失败,在搜索页面关闭的时候,会触发回调
-		 * @param lelinkServiceInfo
-		 * @param easyCastBean
-		 * @param what
-		 * @param extra
-		 */
-		@Override
-		public void onCastError(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean, int what, int extra) {
-		}
-
-		/**
-		 * 推送成功
-		 * @param lelinkServiceInfo
-		 * @param easyCastBean
-		 */
-		@Override
-		public void onCastLoading(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
-		}
-
-		/**
-		 * 暂停
-		 * @param lelinkServiceInfo
-		 * @param easyCastBean
-		 */
-		@Override
-		public void onCastPause(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
-		}
-
-		/**
-		 * 起播 或 收端暂停之后恢复播放
-		 * @param lelinkServiceInfo
-		 * @param easyCastBean
-		 */
-		@Override
-		public void onCastStart(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
-		}
-
-		@Override
-		public void onCastPositionUpdate(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean, long duration, long position) {
-		}
-
-		/**
-		 * 收端播放结束,如果需要实现下一集,可在之后的onCast回调中提供播放信息
-		 * @param lelinkServiceInfo
-		 * @param easyCastBean
-		 */
-		@Override
-		public void onCastCompletion(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
-		}
-
-		/**
-		 * 搜索退出播放,不同于 onCastCompletion,此时需要恢复APP视频播放
-		 * @param lelinkServiceInfo
-		 * @param easyCastBean
-		 */
-		@Override
-		public void onCastStop(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
-		}
-
-		@Override
-		public void onDismiss() {
-		}
-	};
 
 	void init(){
 		videoPlayer = findViewById(R.id.video_play);
 		videoPlayer.setUp(url, true, "null");
 
-		mBrowseContainer = findViewById(R.id.mBrowseContainer);
 
 		//增加title
 		videoPlayer.getTitleTextView().setVisibility(View.GONE);
@@ -169,15 +65,14 @@ public class GSXYVideoPlayerActivity extends Activity {
 		videoPlayer.setIsTouchWiget(isFirst);
 		videoPlayer.setIsTouchWigetFull(isFirst);
 		videoPlayer.setIfCurrentIsFullscreen(false);
-//		videoPlayer.startPlayLogic();
+		videoPlayer.startPlayLogic();
 
 		btn = findViewById(R.id.btn_finish);
 		btn.setOnClickListener(v->{
 			videoPlayer.onVideoPause();
-//			isFirst = !isFirst;
-//			videoPlayer.setIsFinish(isFirst);
-			mBrowseContainer.setVisibility(View.VISIBLE);
-			initLebo();
+			isFirst = !isFirst;
+			videoPlayer.setIsFinish(isFirst);
+			videoPlayer.stopDlan();
 		});
 	}
 

+ 1 - 1
app/src/main/java/com/bestv/edu/activity/SongLyricActivity.kt

@@ -45,7 +45,7 @@ class SongLyricActivity : AppCompatActivity() {
 //            )
             lyricList.forEach {
                 val startIndexTemp = startIndex
-                val duration = (1500 + Math.random() * 500).toLong()
+                val duration = (1500 + it.length*Math.random() * 500).toLong()
                 text.postDelayed(
                     {
                         text.startPlayLine(

+ 84 - 0
app/src/main/java/com/bestv/edu/adapter/DeviceAdapter.java

@@ -0,0 +1,84 @@
+package com.bestv.edu.adapter;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.bestv.edu.R;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.viewholder.BaseViewHolder;
+import com.hpplay.sdk.source.browse.api.LelinkServiceInfo;
+
+import java.util.List;
+
+/**
+ * author : 程中强
+ * e-mail : 740479946@qq.com
+ * date : 2022/9/2114:22
+ * desc :
+ * version: 1.0
+ */
+public class DeviceAdapter extends BaseAdapter {
+
+	private List<LelinkServiceInfo> data;
+	private Context context;
+
+	public DeviceAdapter(Context context, @Nullable List<LelinkServiceInfo> data) {
+
+		this.context = context;
+		this.data = data;
+	}
+
+//	@Override
+//	protected void convert(@NonNull BaseViewHolder helper, LelinkServiceInfo item) {
+//		Log.e("MyTag","设备:"+item.getName());
+//		helper
+//				.setText(R.id.tv_name_item, TextUtils.isEmpty(item.getName())?"":item.getName())
+//
+//		;
+//	}
+
+	@Override
+	public int getCount() {
+		return data.size();
+	}
+
+	@Override
+	public Object getItem(int i) {
+		return data.get(i);
+	}
+
+	@Override
+	public long getItemId(int i) {
+		return i;
+	}
+
+	@Override
+	public View getView(int i, View convertView, ViewGroup viewGroup) {
+		MyViewHolder holder;
+		if (convertView == null) {
+			holder = new MyViewHolder();
+			convertView = LayoutInflater.from(context).inflate(R.layout.item_device, null);
+			holder.tv_name = convertView.findViewById(R.id.tv_name_item);
+			convertView.setTag(holder);
+		} else {
+			holder = (MyViewHolder) convertView.getTag();
+		}
+		Log.e("MyTag","结果收到消息111");
+		holder.tv_name.setText(TextUtils.isEmpty(data.get(i).getName())?"":data.get(i).getName());
+		return convertView;
+	}
+
+	class MyViewHolder {
+		TextView tv_name;
+	}
+}

+ 2 - 0
app/src/main/java/com/bestv/edu/dlan/CastManager.java

@@ -209,6 +209,8 @@ public class CastManager {
             }
         }
     };
+
+
     public INewPlayerListener getPlayerListener() {
         return mPlayerListener;
     }

+ 5 - 3
app/src/main/java/com/bestv/edu/dlan/DLNAControlCenter.java

@@ -53,10 +53,10 @@ public class DLNAControlCenter {
 				.setBindSdkListener(connectManager.getBindListener())
 				.setBrowseResultListener(connectManager.getBrowseListener())
 				.setConnectListener(connectManager.getConnectListener())
-//				.setPlayListener(CastManager.getInstance().getLelinkPlayerListener())
+				.setPlayListener(CastManager.getInstance().getLelinkPlayerListener())
 				//FIXME WARN: 这里替换为您申请的AppID & AppSecret,build.gradle替换为您的应用包名
 //                .setSdkInitInfo(AppVarManager.getInstance().getBaseContext(), "17894", "69ce8955094258d339c1b6eadef2ec09")
-				.setSdkInitInfo(App.getInstance(), "20268", "30ff4917114c5241eddbef00e5be7f6b")
+				.setSdkInitInfo(App.getInstance(), "17894", "69ce8955094258d339c1b6eadef2ec09")
 				.bindSdk();
 	}
 
@@ -191,6 +191,8 @@ public class DLNAControlCenter {
 
 	}
 
-
+	public void setUIListener(IUIUpdateListener mUIListener) {
+		DeviceManager.getInstance().setUIListener(mUIListener);
+	}
 
 }

+ 17 - 11
app/src/main/java/com/bestv/edu/dlan/DeviceManager.java

@@ -20,7 +20,7 @@ public class DeviceManager {
 
     private static DeviceManager sInstance = null;
     private LelinkServiceInfo mSelectInfo;
-//    private IUIUpdateListener mUIListener;
+    private IUIUpdateListener mUIListener;
 
     private IBindSdkListener mBindSdkListener = new IBindSdkListener() {
         @Override
@@ -28,7 +28,11 @@ public class DeviceManager {
             Log.i(TAG, "onBindCallback " + success);
             setPassThroughListener();
             if (success) {
-//                mUIListener.onBindSuccess();
+                Log.e("LeBo","初始化:"+success);
+                if (mUIListener != null) {
+                    mUIListener.onBindSuccess();
+                }
+
             }
         }
     };
@@ -46,9 +50,9 @@ public class DeviceManager {
             } else if (i == IBrowseListener.BROWSE_TIMEOUT) {
                 Log.i(TAG, "搜索超时");
             }
-//            if (mUIListener != null) {
-//                mUIListener.onUpdateDevices(list);
-//            }
+            if (mUIListener != null) {
+                mUIListener.onUpdateDevices(list);
+            }
         }
     };
 
@@ -60,9 +64,9 @@ public class DeviceManager {
                     : protocol == IConnectListener.TYPE_DLNA ? "DLNA"
                     : protocol == IConnectListener.TYPE_IM ? "IM" : ("协议:" + protocol);
             setSelectInfo(lelinkServiceInfo);
-//            if (mUIListener != null) {
-//                mUIListener.onConnect(lelinkServiceInfo);
-//            }
+            if (mUIListener != null) {
+                mUIListener.onConnect(lelinkServiceInfo);
+            }
         }
 
         @Override
@@ -122,13 +126,15 @@ public class DeviceManager {
 
     }
 
+    public void setUIListener(IUIUpdateListener listener) {
+        this.mUIListener = listener;
+    }
+
     public void setSelectInfo(LelinkServiceInfo serviceInfo) {
         mSelectInfo = serviceInfo;
     }
 
-//    public void setUIListener(IUIUpdateListener listener) {
-//        mUIListener = listener;
-//    }
+
 
     public LelinkServiceInfo getSelectInfo() {
         return mSelectInfo;

+ 19 - 0
app/src/main/java/com/bestv/edu/dlan/IUIUpdateListener.java

@@ -0,0 +1,19 @@
+package com.bestv.edu.dlan;
+
+import com.hpplay.sdk.source.browse.api.LelinkServiceInfo;
+
+import java.util.List;
+
+public interface IUIUpdateListener {
+
+    void onUpdateDevices(List<LelinkServiceInfo> list);
+
+    void onConnect(LelinkServiceInfo info);
+
+    void onDisconnect(LelinkServiceInfo info);
+
+    void onNetChanged();
+
+    void onBindSuccess();
+
+}

+ 438 - 2
app/src/main/java/com/bestv/edu/view/VideoPreviewPlay.java

@@ -1,17 +1,47 @@
 package com.bestv.edu.view;
 
 import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.text.TextUtils;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.Gravity;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.RelativeLayout;
 import android.widget.SeekBar;
+import android.widget.TextView;
 import android.widget.Toast;
 
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.bestv.edu.adapter.DeviceAdapter;
+import com.bestv.edu.dlan.CastManager;
+import com.bestv.edu.dlan.DLNAControlCenter;
+import com.bestv.edu.dlan.IUIUpdateListener;
+import com.hpplay.sdk.source.api.INewPlayerListener;
+import com.hpplay.sdk.source.api.LelinkSourceSDK;
+import com.hpplay.sdk.source.bean.CastBean;
+import com.hpplay.sdk.source.browse.api.LelinkServiceInfo;
+import com.hpplay.sdk.source.easycast.IEasyCastListener;
+import com.hpplay.sdk.source.easycast.bean.EasyCastBean;
+import com.shuyu.gsyvideoplayer.utils.CommonUtil;
 import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
 import com.bestv.edu.R;
 import com.bestv.edu.utils.SoundPoolUtil;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * author : 程中强
  * e-mail : 740479946@qq.com
@@ -24,6 +54,22 @@ public class VideoPreviewPlay extends StandardGSYVideoPlayer {
 	private boolean isFinish = false;
 	private SoundPoolUtil soundPoolUtil;
 
+	private ViewGroup mBrowseContainer;//投屏搜索列表
+	private Button btn_cast;//投屏按钮
+	private RelativeLayout rl_dlan_control;//投屏控制层
+	private ImageView dlan_start;//投屏的播放暂停
+	private TextView dlan_current,dlan_total;//投屏的时长
+	private SeekBar dlan_progress;//投屏进度条
+	private boolean isDlanPlay = false;
+	public List<LelinkServiceInfo> mDevices = new ArrayList<>();
+	public LelinkServiceInfo curTPDevice;
+
+	private DeviceAdapter mDeviceAdapter;
+	private ListView rvList;
+	private IUIUpdateListener mUIListener;
+	private INewPlayerListener mPushListener;
+	private IEasyCastListener mCastListener;
+
 	public void setIsFinish(boolean isFinish){
 		this.isFinish = isFinish;
 	}
@@ -41,14 +87,101 @@ public class VideoPreviewPlay extends StandardGSYVideoPlayer {
 
 	@Override
 	public int getLayoutId() {
-		return super.getLayoutId();
+		return R.layout.activity_my_video;
 	}
 
+	public void stopDlan(){
+		LelinkSourceSDK.getInstance().stopPlay();
+	}
+
+	private Handler handler = new Handler(){
+		@Override
+		public void handleMessage(@NonNull Message msg) {
+			super.handleMessage(msg);
+			switch (msg.what){
+				case 1001:
+					Log.e("MyTag","结果收到消息");
+//					if (mDeviceAdapter != null) {
+						mDeviceAdapter.notifyDataSetChanged();
+					rvList.setAdapter(mDeviceAdapter);
+//					}
+					break;
+			}
+		}
+	};
+
 	@Override
 	protected void init(Context context) {
 		super.init(context);
+
 		soundPoolUtil= SoundPoolUtil.getInstance(context);
-		mProgressBar = (SeekBar) findViewById(R.id.progress);
+		mProgressBar = findViewById(R.id.progress);
+		dlan_progress = findViewById(R.id.dlan_progress);
+		mBrowseContainer = findViewById(R.id.mBrowseContainer);
+		btn_cast = findViewById(R.id.btn_cast);
+		rl_dlan_control = findViewById(R.id.rl_dlan_control);
+		dlan_start = findViewById(R.id.dlan_start);
+		dlan_current = findViewById(R.id.dlan_current);
+		dlan_total = findViewById(R.id.dlan_total);
+
+		rvList = findViewById(R.id.rv_device);
+//		rvList.setLayoutManager(new LinearLayoutManager(context));
+		mDevices = new ArrayList<>();
+//		mDevices.clear();
+		mDeviceAdapter = new DeviceAdapter(context, mDevices);
+		rvList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+			@Override
+			public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
+				curTPDevice = mDevices.get(i);
+
+				DLNAControlCenter.getInstance().dlnaPlay(curTPDevice, mOriginUrl, "",0);
+
+//			new Handler().postDelayed(new Runnable() {
+//				@Override
+//				public void run() {
+//					DLNAControlCenter.getInstance().dlnaSeekToPlayPosition(curTPDevice, (int) (ijkVrVideoView.getCurrentPosition() / 1000.0f));
+//				}
+//			}, 3000);
+			}
+		});
+
+		dlan_start.setOnClickListener(v->{
+
+			if (isDlanPlay) {
+				dlan_start.setImageResource(R.drawable.video_play_normal);
+				LelinkSourceSDK.getInstance().pause();
+			} else {
+				dlan_start.setImageResource(R.drawable.video_pause_normal);
+				LelinkSourceSDK.getInstance().resume();
+			}
+		});
+
+		btn_cast.setOnClickListener(v->{
+			LelinkSourceSDK.getInstance().setEasyCastListener(mCastListener);
+			LelinkSourceSDK.getInstance().easyPush(mBrowseContainer);
+//			LelinkSourceSDK.getInstance().setNewPlayListener(mPushListener);
+//			mDevices.clear();
+			onVideoPause();
+			mBrowseContainer.setVisibility(VISIBLE);
+//			DLNAControlCenter.getInstance().startLelinkSearch();
+		});
+		dlan_progress.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+			@Override
+			public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
+
+			}
+
+			@Override
+			public void onStartTrackingTouch(SeekBar seekBar) {
+
+			}
+
+			@Override
+			public void onStopTrackingTouch(SeekBar seekBar) {
+				Log.e("MyTag","拖动:"+seekBar.getProgress()*getDuration()/100/1000);
+				LelinkSourceSDK.getInstance().seekTo(seekBar.getProgress()*getDuration()/100/1000);
+			}
+		});
 
 
 		mProgressBar.setOnTouchListener(new OnTouchListener() {
@@ -64,5 +197,308 @@ public class VideoPreviewPlay extends StandardGSYVideoPlayer {
 				return false;
 			}
 		});
+
+
+
+
+		initCast();
+	}
+
+	void initCast(){
+		mUIListener = new IUIUpdateListener() {
+			@Override
+			public void onUpdateDevices(List<LelinkServiceInfo> list) {
+				for (LelinkServiceInfo lelinkServiceInfo : list) {
+					if (mDevices.contains(lelinkServiceInfo)) {
+						continue;
+					} else {
+						mDevices.add(lelinkServiceInfo);
+
+						handler.sendEmptyMessage(1001);
+					}
+				}
+			}
+
+			@Override
+			public void onConnect(LelinkServiceInfo info) {
+//			lelinkCastSuccess(true);
+			}
+
+
+			@Override
+			public void onDisconnect(LelinkServiceInfo info) {
+//			DLNAControlCenter.getInstance().uploadCastDataToPlatform(false, curTPDevice, titleId);
+			}
+
+			@Override
+			public void onNetChanged() {
+			}
+
+			@Override
+			public void onBindSuccess() {
+			}
+		};
+
+		mPushListener = new INewPlayerListener() {
+
+			/**
+			 * @param bean 投屏信息
+			 *  内容开始加载
+			 */
+			@Override
+			public void onLoading(CastBean bean) {
+				btn_cast.setVisibility(GONE);
+				rl_dlan_control.setVisibility(VISIBLE);
+				isDlanPlay = true;
+				dlan_total.setText(mTotalTimeTextView.getText());
+			}
+
+			/**
+			 * @param bean 投屏信息
+			 *  开始播放
+			 */
+			@Override
+			public void onStart(CastBean bean) {
+				dlan_start.setImageResource(R.drawable.video_pause_normal);
+				isDlanPlay = true;
+			}
+			/**
+			 * @param bean 投屏信息
+			 *  播放暂停
+			 */
+			@Override
+			public void onPause(CastBean bean) {
+				dlan_start.setImageResource(R.drawable.video_play_normal);
+				isDlanPlay = false;
+			}
+			/**
+			 * 播放完成
+			 * @param bean 投屏信息
+			 * @param type 播放类型
+			 */
+			@Override
+			public void onCompletion(CastBean bean, int type) {
+				btn_cast.setVisibility(VISIBLE);
+				rl_dlan_control.setVisibility(GONE);
+				isDlanPlay = false;
+				onVideoResume();
+//			LelinkSourceSDK.getInstance().disconnect(lelinkServiceInfo);
+			}
+
+			/**
+			 * @param bean 投屏信息
+			 *  播放停止 (主动停止或者电视端停止均会回调)
+			 */
+			@Override
+			public void onStop(CastBean bean) {
+				isDlanPlay = false;
+				btn_cast.setVisibility(VISIBLE);
+				rl_dlan_control.setVisibility(GONE);
+				onVideoResume();
+			}
+			/**
+			 * 该接口暂未有数据回调
+			 */
+			@Override
+			public void onSeekComplete(CastBean bean, int position) {
+
+			}
+
+			/**
+			 * info信息回调,播放信息和收端能力查询等回调接口
+			 */
+			@Override
+			public void onInfo(CastBean bean, int what, int extra) {
+			}
+
+			/**
+			 * (重载接口)
+			 */
+			@Override
+			public void onInfo(CastBean bean, int what, String data) {
+
+			}
+
+			/**
+			 * @param bean 投屏信息
+			 * @param what 错误类型
+			 * @param extra 额外错误码
+			 */
+			@Override
+			public void onError(CastBean bean, int what, int extra) {
+				String text = "未知异常";
+				switch (extra) {
+					case EXTRA_ERROR_AUTH:
+					case EXTRA_ERROR_AUTH_TIME_DONE:
+						text = "SDK认证失败";
+						break;
+					case EXTRA_NEED_SCREEN_CODE:
+						text = "请输入密码";
+//					getActivity().runOnUiThread(new Runnable() {
+//						@Override
+//						public void run() {
+//							showPWDDialog();
+//						}
+//					});
+						break;
+					case EXTRA_DEVICE_OFFLINE:
+						text = "接收端不在线";
+						break;
+					case EXTRA_ERROR_PUSH_IO:
+						text = "网络通讯异常";
+						break;
+				}
+				if (TextUtils.isEmpty(text)) {
+					text = "推送 onError " + what + "/" + extra;
+				}
+			}
+
+			/**
+			 *
+			 * 该接口暂未有数据回调
+			 */
+			@Override
+			public void onVolumeChanged(CastBean bean, float percent) {
+
+			}
+
+			/**
+			 * 进度更新回调
+			 * @param bean 投屏信息
+			 * @param duration 最大进度 (单位秒)
+			 * @param position 当前进度 (单位秒)
+			 */
+			@Override
+			public void onPositionUpdate(CastBean bean, long duration, long position) {
+				if(duration!=0)
+					dlan_progress.setProgress((int) (position*100/duration));
+				dlan_current.setText(CommonUtil.stringForTime((int) position*1000));
+			}
+		};
+
+//		DLNAControlCenter.getInstance().setUIListener(mUIListener);
+//		CastManager.getInstance().addPlayerListener(mPushListener);
+
+		mCastListener = new IEasyCastListener() {
+
+			/**
+			 * 如果没有触发此回调,则表示此次未搜索到设备或用户未投屏
+			 * @param lelinkServiceInfo
+			 * @return
+			 */
+			@Override
+			public EasyCastBean onCast(LelinkServiceInfo lelinkServiceInfo) {
+				EasyCastBean bean = new EasyCastBean();
+				bean.url = mOriginUrl; //实际需要投屏的url
+				return bean;
+			}
+
+			/**
+			 * 如果投屏失败,在搜索页面关闭的时候,会触发回调
+			 * @param lelinkServiceInfo
+			 * @param easyCastBean
+			 * @param what
+			 * @param extra
+			 */
+			@Override
+			public void onCastError(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean, int what, int extra) {
+				Log.e("MyTag","推送失败"+what+"   "+extra);
+				btn_cast.setVisibility(VISIBLE);
+				mBrowseContainer.setVisibility(GONE);
+				rl_dlan_control.setVisibility(GONE);
+				isDlanPlay = false;
+				onVideoResume();
+			}
+
+			/**
+			 * 推送成功
+			 * @param lelinkServiceInfo
+			 * @param easyCastBean
+			 */
+			@Override
+			public void onCastLoading(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
+				Log.e("MyTag","推送成功");
+				btn_cast.setVisibility(GONE);
+				mBrowseContainer.setVisibility(GONE);
+				rl_dlan_control.setVisibility(VISIBLE);
+				isDlanPlay = true;
+				dlan_total.setText(mTotalTimeTextView.getText());
+			}
+
+			/**
+			 * 暂停
+			 * @param lelinkServiceInfo
+			 * @param easyCastBean
+			 */
+			@Override
+			public void onCastPause(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
+				dlan_start.setImageResource(R.drawable.video_play_normal);
+				isDlanPlay = false;
+			}
+
+			/**
+			 * 起播 或 收端暂停之后恢复播放
+			 * @param lelinkServiceInfo
+			 * @param easyCastBean
+			 */
+			@Override
+			public void onCastStart(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
+				dlan_start.setImageResource(R.drawable.video_pause_normal);
+				isDlanPlay = true;
+			}
+
+			@Override
+			public void onCastPositionUpdate(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean, long duration, long position) {
+				Log.e("MyTag","当前:"+position);
+				if(duration!=0)dlan_progress.setProgress((int) (position*100/duration));
+				dlan_current.setText(CommonUtil.stringForTime((int) position*1000));
+			}
+
+			/**
+			 * 收端播放结束,如果需要实现下一集,可在之后的onCast回调中提供播放信息
+			 * @param lelinkServiceInfo
+			 * @param easyCastBean
+			 */
+			@Override
+			public void onCastCompletion(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
+				btn_cast.setVisibility(VISIBLE);
+				rl_dlan_control.setVisibility(GONE);
+				mBrowseContainer.setVisibility(GONE);
+				isDlanPlay = false;
+				onVideoResume();
+//				LelinkSourceSDK.getInstance().disconnect(lelinkServiceInfo);
+			}
+
+			/**
+			 * 搜索退出播放,不同于 onCastCompletion,此时需要恢复APP视频播放
+			 * @param lelinkServiceInfo
+			 * @param easyCastBean
+			 */
+			@Override
+			public void onCastStop(LelinkServiceInfo lelinkServiceInfo, EasyCastBean easyCastBean) {
+				isDlanPlay = false;
+				btn_cast.setVisibility(VISIBLE);
+				rl_dlan_control.setVisibility(GONE);
+				mBrowseContainer.setVisibility(GONE);
+				onVideoResume();
+//				LelinkSourceSDK.getInstance().disconnect(lelinkServiceInfo);
+			}
+
+			@Override
+			public void onDismiss() {
+				btn_cast.setVisibility(VISIBLE);
+				rl_dlan_control.setVisibility(GONE);
+				mBrowseContainer.setVisibility(GONE);
+				isDlanPlay = false;
+				onVideoResume();
+//			LelinkSourceSDK.getInstance().stopPlay();
+			}
+		};
 	}
+
+
+
+
+
+
 }

+ 0 - 5
app/src/main/res/layout/activity_gsxy_video.xml

@@ -16,10 +16,5 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"/>
 
-    <RelativeLayout
-        android:id="@+id/mBrowseContainer"
-        android:visibility="gone"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
 
 </RelativeLayout>

+ 269 - 0
app/src/main/res/layout/activity_my_video.xml

@@ -0,0 +1,269 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@android:color/black">
+    <RelativeLayout
+        android:id="@+id/surface_container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:gravity="center">
+
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/thumb"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_alignParentStart="true"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentEnd="true"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true"
+        android:background="#000000"
+        android:scaleType="fitCenter" />
+
+    <LinearLayout
+        android:id="@+id/layout_bottom"
+        android:layout_width="match_parent"
+        android:layout_height="40dp"
+        android:layout_alignParentBottom="true"
+        android:background="#99000000"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        android:visibility="invisible">
+
+        <TextView
+            android:id="@+id/current"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="16dp"
+            android:text="00:00"
+            android:textColor="#ffffff" />
+
+        <SeekBar
+            android:id="@+id/progress"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_weight="1.0"
+            android:background="@null"
+            android:max="100"
+            android:maxHeight="4dp"
+            android:minHeight="4dp"
+            android:paddingTop="8dp"
+            android:paddingBottom="8dp"
+            android:progressDrawable="@drawable/video_seek_progress"
+            android:thumb="@drawable/video_seek_thumb" />
+
+        <TextView
+            android:id="@+id/total"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginRight="16dp"
+            android:text="00:00"
+            android:textColor="#ffffff" />
+
+        <ImageView
+            android:id="@+id/fullscreen"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:paddingRight="16dp"
+            android:scaleType="center"
+            android:src="@drawable/video_enlarge" />
+    </LinearLayout>
+
+    <ProgressBar
+        android:id="@+id/bottom_progressbar"
+        style="?android:attr/progressBarStyleHorizontal"
+        android:layout_width="match_parent"
+        android:layout_height="1.5dp"
+        android:layout_alignParentBottom="true"
+        android:max="100"
+        android:progressDrawable="@drawable/video_progress" />
+
+    <ImageView
+        android:id="@+id/back_tiny"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginLeft="6dp"
+        android:layout_marginTop="6dp"
+        android:visibility="gone" />
+
+
+    <ProgressBar
+        android:id="@+id/loading"
+        style="?android:attr/progressBarStyleLarge"
+        android:layout_width="28dp"
+        android:layout_height="28dp"
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"
+        android:visibility="invisible" />
+
+
+    <ImageView
+        android:id="@+id/start"
+        android:layout_width="60dp"
+        android:layout_height="60dp"
+        android:layout_centerInParent="true"
+        android:layout_gravity="center_vertical"
+        android:src="@drawable/video_click_play_selector" />
+
+
+    <ImageView
+        android:id="@+id/small_close"
+        android:layout_width="30dp"
+        android:layout_height="30dp"
+        android:paddingLeft="10dp"
+        android:paddingTop="10dp"
+        android:scaleType="centerInside"
+        android:src="@drawable/video_small_close"
+        android:visibility="gone" />
+
+    <ImageView
+        android:id="@+id/lock_screen"
+        android:layout_width="30dp"
+        android:layout_height="30dp"
+        android:layout_alignParentRight="true"
+        android:layout_centerVertical="true"
+        android:layout_marginRight="50dp"
+        android:scaleType="centerInside"
+        android:src="@drawable/unlock"
+        android:visibility="gone" />
+
+    <LinearLayout
+        android:id="@+id/layout_top"
+        android:layout_width="match_parent"
+        android:layout_height="48dp"
+        android:layout_alignParentTop="true"
+        android:layout_toEndOf="@+id/back_tiny"
+        android:layout_toRightOf="@+id/back_tiny"
+        android:background="@drawable/video_title_bg"
+        android:gravity="center_vertical">
+
+        <ImageView
+            android:id="@+id/back"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:paddingLeft="10dp"
+            android:scaleType="centerInside"
+            android:src="@drawable/video_back" />
+
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:paddingLeft="10dp"
+            android:textColor="@android:color/white"
+            android:textSize="18sp" />
+    </LinearLayout>
+
+
+
+    <RelativeLayout
+        android:id="@+id/preview_layout"
+        android:layout_width="@dimen/seek_bar_image"
+        android:layout_height="100dp"
+        android:layout_above="@+id/layout_bottom"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="30dp"
+        android:visibility="gone">
+
+        <ImageView
+            android:id="@+id/preview_image"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="#000000" />
+    </RelativeLayout>
+
+
+    <Button
+        android:id="@+id/btn_cast"
+        android:text="投屏"
+        android:visibility="visible"
+        android:layout_marginRight="100dp"
+        android:layout_alignParentRight="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <RelativeLayout
+        android:id="@+id/mBrowseContainer"
+        android:visibility="gone"
+        android:background="#000000"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+        <ListView
+            android:id="@+id/rv_device"
+            android:visibility="gone"
+            android:background="#FFF"
+            android:layout_marginTop="100dp"
+            android:layout_centerHorizontal="true"
+            android:layout_width="300dp"
+            android:layout_height="match_parent"/>
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/rl_dlan_control"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@android:color/black"
+        android:visibility="gone">
+
+        <ImageView
+            android:id="@+id/dlan_start"
+            android:layout_width="60dp"
+            android:layout_height="60dp"
+            android:layout_centerInParent="true"
+            android:layout_gravity="center_vertical"
+            android:src="@drawable/video_pause_normal" />
+
+        <LinearLayout
+            android:id="@+id/dlan_layout_bottom"
+            android:layout_width="match_parent"
+            android:layout_height="40dp"
+            android:layout_alignParentBottom="true"
+            android:background="#99000000"
+            android:gravity="center_vertical"
+            android:orientation="horizontal"
+            android:visibility="visible">
+
+            <TextView
+                android:id="@+id/dlan_current"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="16dp"
+                android:text="00:00"
+                android:textColor="#ffffff" />
+
+            <SeekBar
+                android:id="@+id/dlan_progress"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_vertical"
+                android:layout_weight="1.0"
+                android:background="@null"
+                android:max="100"
+                android:maxHeight="4dp"
+                android:minHeight="4dp"
+                android:paddingTop="8dp"
+                android:paddingBottom="8dp"
+                android:progressDrawable="@drawable/video_seek_progress"
+                android:thumb="@drawable/video_seek_thumb" />
+
+            <TextView
+                android:id="@+id/dlan_total"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="16dp"
+                android:text="00:00"
+                android:textColor="#ffffff" />
+
+        </LinearLayout>
+
+    </RelativeLayout>
+
+</RelativeLayout>

+ 14 - 0
app/src/main/res/layout/item_device.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <TextView
+        android:id="@+id/tv_name_item"
+        android:text="sheb"
+        android:layout_centerInParent="true"
+        android:textSize="20sp"
+        android:gravity="center"
+        android:layout_width="200dp"
+        android:padding="30dp"
+        android:layout_height="wrap_content"/>
+</RelativeLayout>