|
|
@@ -17,6 +17,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.VideoView;
|
|
|
|
|
|
+import com.danikula.videocache.CacheListener;
|
|
|
import com.kfzs.duanduan.utils.StatusBarUtils;
|
|
|
import com.sheep.gamegroup.absBase.BaseUMActivity;
|
|
|
import com.sheep.gamegroup.absBase.IRefresh;
|
|
|
@@ -39,6 +40,7 @@ import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
@@ -50,7 +52,7 @@ import io.reactivex.schedulers.Schedulers;
|
|
|
* realicing@sina.com
|
|
|
* 小绵羊3.4.5新增 -- 视频详情
|
|
|
*/
|
|
|
-public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfoListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener {
|
|
|
+public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfoListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, CacheListener {
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
@@ -150,6 +152,8 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
videoView.setOnCompletionListener(this);
|
|
|
// videoView.setMediaController(new MediaController(this));
|
|
|
videoView.setVideoURI(getUri());
|
|
|
+// videoView.setVideoPath(getUrl());
|
|
|
+// videoView.start();
|
|
|
resetVideoOrientation();
|
|
|
}
|
|
|
//重新设置视频的方向,videoView没法设置方向
|
|
|
@@ -157,9 +161,16 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
// if(orientation > 0 && orientation < 360)
|
|
|
// videoView.setRotation(orientation);
|
|
|
}
|
|
|
+ private boolean isResister = false;
|
|
|
+ //转化地址
|
|
|
+ private String getUrl(){
|
|
|
+ if(isResister)
|
|
|
+ SheepApp.getHttpProxyCacheServer().registerCacheListener(this, video_url);
|
|
|
+ return SheepApp.getHttpProxyCacheServer().getProxyUrl(video_url);
|
|
|
+ }
|
|
|
//转化地址
|
|
|
private Uri getUri(){
|
|
|
- String proxyUrl = SheepApp.getHttpProxyCacheServer().getProxyUrl(video_url);
|
|
|
+ String proxyUrl = getUrl();
|
|
|
Uri uri = Uri.parse(proxyUrl);
|
|
|
LogUtil.println(ActVideoDetail.class.getSimpleName(),"\n", video_url, "\n", proxyUrl);
|
|
|
return uri;
|
|
|
@@ -229,6 +240,10 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
public void onClickAddVideo(View view) {
|
|
|
Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO);
|
|
|
}
|
|
|
+ //点击返回
|
|
|
+ public void onClickBackImg(View view) {
|
|
|
+ onBackPressed();
|
|
|
+ }
|
|
|
//点击头像跳转用户游戏主页
|
|
|
public void onClickAvatar(View view) {
|
|
|
if (user_id > 0)
|
|
|
@@ -380,6 +395,8 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
return;
|
|
|
}
|
|
|
videoView.stopPlayback();
|
|
|
+ if(isResister)
|
|
|
+ SheepApp.getHttpProxyCacheServer().unregisterCacheListener(this, video_url);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -527,7 +544,7 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
@Override
|
|
|
public boolean onInfo(MediaPlayer mediaPlayer, int what, int extra) {
|
|
|
LogUtil.println("ActPlayVideo", "onInfo what = " + what + " extra = " + extra);
|
|
|
- if (!mediaPlayer.isLooping())
|
|
|
+ if(!mediaPlayer.isLooping())
|
|
|
mediaPlayer.setLooping(true);
|
|
|
switch (what) {
|
|
|
case MediaPlayer.MEDIA_INFO_BUFFERING_START:
|
|
|
@@ -555,8 +572,9 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
|
|
|
@Override
|
|
|
public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
|
|
|
- LogUtil.println("ActPlayVideo", "onInfo what = " + what + " extra = " + extra);
|
|
|
- return false;
|
|
|
+ LogUtil.println("ActPlayVideo", "onError what = " + what + " extra = " + extra);
|
|
|
+ initPlay();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -564,4 +582,8 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
|
|
|
LogUtil.println("ActPlayVideo", "onCompletion");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onCacheAvailable(File cacheFile, String url, int percentsAvailable) {
|
|
|
+ LogUtil.println("ActPlayVideo", "onCacheAvailable", cacheFile.getAbsolutePath(), url, percentsAvailable);
|
|
|
+ }
|
|
|
}
|