forked from CarGuo/GSYVideoPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
557dab0
commit b009b08
Showing
18 changed files
with
722 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
app/src/main/java/com/example/gsyvideoplayer/switchplay/SwitchDetailActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package com.example.gsyvideoplayer.switchplay; | ||
|
||
import android.content.res.Configuration; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import com.example.gsyvideoplayer.R; | ||
import com.shuyu.gsyvideoplayer.GSYVideoManager; | ||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder; | ||
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack; | ||
import com.shuyu.gsyvideoplayer.listener.LockClickListener; | ||
import com.shuyu.gsyvideoplayer.utils.OrientationUtils; | ||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; | ||
|
||
/** | ||
* 切换详情 | ||
*/ | ||
public class SwitchDetailActivity extends AppCompatActivity { | ||
|
||
public static final String URL = "url"; | ||
|
||
SwitchVideo detailPlayer; | ||
|
||
private boolean isPlay = true; | ||
private boolean isPause; | ||
|
||
private OrientationUtils orientationUtils; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.switch_activity_detail_player); | ||
|
||
detailPlayer = (SwitchVideo) findViewById(R.id.detail_player); | ||
|
||
|
||
//增加title | ||
detailPlayer.getTitleTextView().setVisibility(View.GONE); | ||
detailPlayer.getBackButton().setVisibility(View.GONE); | ||
|
||
//外部辅助的旋转,帮助全屏 | ||
orientationUtils = new OrientationUtils(this, detailPlayer); | ||
//初始化不打开外部的旋转 | ||
orientationUtils.setEnable(false); | ||
|
||
SwitchUtil.optionPlayer(detailPlayer, getIntent().getStringExtra(URL), true, "这是title"); | ||
|
||
SwitchUtil.clonePlayState(detailPlayer); | ||
|
||
detailPlayer.setIsTouchWiget(true); | ||
|
||
detailPlayer.setVideoAllCallBack(new GSYSampleCallBack() { | ||
@Override | ||
public void onPrepared(String url, Object... objects) { | ||
super.onPrepared(url, objects); | ||
//开始播放了才能旋转和全屏 | ||
orientationUtils.setEnable(true); | ||
} | ||
|
||
@Override | ||
public void onQuitFullscreen(String url, Object... objects) { | ||
super.onQuitFullscreen(url, objects); | ||
if (orientationUtils != null) { | ||
orientationUtils.backToProtVideo(); | ||
} | ||
} | ||
}); | ||
|
||
detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
//直接横屏 | ||
orientationUtils.resolveByClick(); | ||
//第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar | ||
detailPlayer.startWindowFullscreen(SwitchDetailActivity.this, true, true); | ||
} | ||
}); | ||
|
||
detailPlayer.setSurfaceToPlay(); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (orientationUtils != null) { | ||
orientationUtils.backToProtVideo(); | ||
} | ||
if (GSYVideoManager.backFromWindowFull(this)) { | ||
return; | ||
} | ||
super.onBackPressed(); | ||
} | ||
|
||
|
||
@Override | ||
protected void onPause() { | ||
detailPlayer.getCurrentPlayer().onVideoPause(); | ||
super.onPause(); | ||
isPause = true; | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
detailPlayer.getCurrentPlayer().onVideoResume(false); | ||
super.onResume(); | ||
isPause = false; | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
detailPlayer.getGSYVideoManager().setListener(detailPlayer.getGSYVideoManager().lastListener()); | ||
detailPlayer.getGSYVideoManager().setLastListener(null); | ||
GSYVideoManager.releaseAllVideos(); | ||
if (orientationUtils != null) | ||
orientationUtils.releaseListener(); | ||
|
||
SwitchUtil.release(); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void onConfigurationChanged(Configuration newConfig) { | ||
super.onConfigurationChanged(newConfig); | ||
//如果旋转了就全屏 | ||
if (isPlay && !isPause) { | ||
detailPlayer.onConfigurationChanged(this, newConfig, orientationUtils, true, true); | ||
} | ||
} | ||
|
||
} |
84 changes: 84 additions & 0 deletions
84
app/src/main/java/com/example/gsyvideoplayer/switchplay/SwitchListVideoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.example.gsyvideoplayer.switchplay; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.AbsListView; | ||
import android.widget.ListView; | ||
|
||
import com.example.gsyvideoplayer.R; | ||
import com.example.gsyvideoplayer.simple.adapter.SimpleListVideoModeAdapter; | ||
import com.shuyu.gsyvideoplayer.GSYVideoManager; | ||
|
||
/** | ||
* 可切换列表 | ||
*/ | ||
public class SwitchListVideoActivity extends AppCompatActivity { | ||
|
||
ListView videoList; | ||
|
||
SwitchListVideoAdapter listNormalAdapter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_list_video); | ||
|
||
videoList = (ListView)findViewById(R.id.video_list); | ||
|
||
listNormalAdapter = new SwitchListVideoAdapter(this); | ||
videoList.setAdapter(listNormalAdapter); | ||
|
||
videoList.setOnScrollListener(new AbsListView.OnScrollListener() { | ||
@Override | ||
public void onScrollStateChanged(AbsListView view, int scrollState) { | ||
} | ||
|
||
@Override | ||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { | ||
int lastVisibleItem = firstVisibleItem + visibleItemCount; | ||
//大于0说明有播放 | ||
if (GSYVideoManager.instance().getPlayPosition() >= 0) { | ||
//当前播放的位置 | ||
int position = GSYVideoManager.instance().getPlayPosition(); | ||
//对应的播放列表TAG | ||
if (GSYVideoManager.instance().getPlayTag().equals(SwitchListVideoAdapter.TAG) | ||
&& (position < firstVisibleItem || position > lastVisibleItem)) { | ||
if(GSYVideoManager.isFullState(SwitchListVideoActivity.this)) { | ||
return; | ||
} | ||
//如果滑出去了上面和下面就是否,和今日头条一样 | ||
GSYVideoManager.releaseAllVideos(); | ||
listNormalAdapter.notifyDataSetChanged(); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (GSYVideoManager.backFromWindowFull(this)) { | ||
return; | ||
} | ||
super.onBackPressed(); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
//GSYVideoManager.onPause(); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
//GSYVideoManager.onResume(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
GSYVideoManager.releaseAllVideos(); | ||
} | ||
} |
Oops, something went wrong.