doc/UPDATE_VERSION_EN.md
Click to see the Chinese version
setDatabaseProvider method ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
@Override
public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) {
//If it returns null, the default will be used
return null;
}
/**
* Through a custom HttpDataSource, you can set a self-signed certificate or ignore the certificate
* The GSYExoHttpDataSourceFactory in the demo uses an ignored certificate
* */
@Override
public DataSource.Factory getHttpDataSourceFactory(String userAgent, @Nullable TransferListener listener, int connectTimeoutMillis, int readTimeoutMillis,
Map<String, String> mapHeadData, boolean allowCrossProtocolRedirects) {
//If it returns null, the default will be used
GSYExoHttpDataSourceFactory factory = new GSYExoHttpDataSourceFactory(userAgent, listener,
connectTimeoutMillis,
readTimeoutMillis, allowCrossProtocolRedirects);
factory.setDefaultRequestProperties(mapHeadData);
return factory;
}
});
ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
@Override
public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) {
//If it returns null, the default will be used
return null;
}
/**
* Through a custom HttpDataSource, you can set a self-signed certificate or ignore the certificate
* The GSYExoHttpDataSourceFactory in the demo uses an ignored certificate
* */
@Override
public HttpDataSource.BaseFactory getHttpDataSourceFactory(String userAgent, @Nullable TransferListener listener, int connectTimeoutMillis, int readTimeoutMillis, boolean allowCrossProtocolRedirects) {
//If it returns null, the default will be used
return new GSYExoHttpDataSourceFactory(userAgent, listener,
connectTimeoutMillis,
readTimeoutMillis, allowCrossProtocolRedirects);
}
});
ExoSourceManager
public static void setHttpReadTimeout(int httpReadTimeout)
public static void setHttpConnectTimeout(int httpConnectTimeout)
String url = RawResourceDataSource.buildRawResourceUri(R.raw.test).toString();
GSYVideoType.setScreenScaleRatio
/**
* Whether to adapt to the problem that the title display is covered due to the space occupied by the notch screen or the perforated screen in vertical and horizontal screens
*
* @param needAutoAdaptation default false
*/
public void setNeedAutoAdaptation(boolean needAutoAdaptation)
GSYVideoManager
.instance()
.setPlayerInitSuccessListener(new IPlayerInitSuccessListener() {
///Player initialization success callback, which can be used for custom settings before playback
@Override
public void onPlayerInitSuccess(IMediaPlayer player, GSYModel model) {
if (player instanceof IjkExo2MediaPlayer) {
((IjkExo2MediaPlayer) player).setTrackSelector(new DefaultTrackSelector());
((IjkExo2MediaPlayer) player).setLoadControl(new DefaultLoadControl());
}
}
});
Map<String, String> header = new HashMap<>();
header.put("allowCrossProtocolRedirects", "true");
xxx.setMapHeadData(header)
//Set the adjacent frame of seek.
if(detailPlayer.getGSYVideoManager().getPlayer() instanceof Exo2PlayerManager) {
((Exo2PlayerManager) detailPlayer.getGSYVideoManager().getPlayer()).setSeekParameter(SeekParameters.NEXT_SYNC);
Debuger.printfError("***** setSeekParameter **** ");
}
ExoSourceManager.setSkipSSLChain(true);
orientationUtils.setIsPause(true);
overrideExtension to exoPlayerPlayerFactory.setPlayManager(Exo2PlayerManager.class);//EXO mode
PlayerFactory.setPlayManager(SystemPlayerManager.class);//System mode
PlayerFactory.setPlayManager(IjkPlayerManager.class);//ijk mode
CacheFactory.setCacheManager(ExoPlayerCacheManager.class);//exo cache mode, supports m3u8, only supports exo
CacheFactory.setCacheManager(ProxyCacheManager.class);//Proxy cache mode, supports all modes, does not support m3u8, etc.
//PlayerFactory.setPlayManager(new Exo2PlayerManager());//EXO mode
//PlayerFactory.setPlayManager(new SystemPlayerManager());//System mode
//PlayerFactory.setPlayManager(new IjkPlayerManager());//ijk mode
//CacheFactory.setCacheManager(new ExoPlayerCacheManager());//exo cache mode, supports m3u8, only supports exo
//CacheFactory.setCacheManager(new ProxyCacheManager());//Proxy cache mode, supports all modes, does not support m3u8, etc.
ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
/**
* @param dataSource link
* @param preview Whether to bring the header, the default is true if there is a header
* @param cacheEnable Whether to cache
* @param isLooping Whether to loop
* @param cacheDir Custom cache directory
* @return When the return is not empty, use the returned custom mediaSource
*/
@Override
public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) {
return null;
}
});
logLevel and ijkLibLoader are set directly through the IJKPlayerManager static method/**
* Whether to automatically select vertical full screen or horizontal full screen according to the video size. Note that the default rotation is invalid at this time.
* @param autoFullWithSize default false
*/
public void setAutoFullWithSize(boolean autoFullWithSize)
String url = "android.resource://" + getPackageName() + "/" + R.raw.test;
GSYVideoManager.instance().enableRawPlay(getApplicationContext());
/*
* Whether it is currently in full screen state
*
* @return Whether it is currently in full screen state, true means yes.
*/
public static boolean isFullState(Activity activity)
XXXXManager related
/**
* Resume paused state
*
* @param seek Whether to generate a seek action, live broadcast is set to false
*/
public static void onResume(String key, boolean seek)
Video related
/**
* Resume paused state
*
* @param seek Whether to generate a seek action
*/
@Override
public void onVideoResume(boolean seek)
GSYSampleADVideoPlayer and DetailADPlayerplayNext() interface.getGSYVideoManager() method to implement your own Manager.CustomRenderVideoPlayer in the demo demonstrates how to set a custom rendering layer.ListMultiVideoActivity and MultiSampleVideo demonstrate how to play multiple videos at the same time.DetailADPlayer2 and ListADVideoActivity demonstrate ad and intermediate insertion ad support./**
* Long time loss of audio focus, pause the player
*
* @param releaseWhenLossAudio default true, only pause when false
*/
public void setReleaseWhenLossAudio(boolean releaseWhenLossAudio)
Add PlayerManager, update to ExoPlayer2, and optimize support for ExoPlayer2.
Add system player AndroidMediaPlayer support
Add setUpLazy method for the list to optimize possible sliding lag in the list
/**
* The real setup is performed when the play is clicked
*/
public boolean setUpLazy(String url, boolean cacheWithPlay, File cachePath, Map<String, String> mapHeadData, String title)
Optimize GL rendering and handle crash when switching rendering effects.
DEMO adds SamllVideoHelper to implement small window logic and update the demo
Optimize the pop-up box for touch volume, brightness, and progress, and optimize the degree of customization
/**
* layoutId of the touch progress dialog
* Can be returned by overriding after inheritance
* If there is a custom implementation logic, you can override the showProgressDialog method
*/
protected int getProgressDialogLayoutId()
/**
* progress bar id of the touch progress dialog
* Can be returned by overriding after inheritance, if not, it can be empty
* If there is a custom implementation logic, you can override the showProgressDialog method
*/
protected int getProgressDialogProgressId()
/**
* Current time text of the touch progress dialog
* Can be returned by overriding after inheritance, if not, it can be empty
* If there is a custom implementation logic, you can override the showProgressDialog method
*/
protected int getProgressDialogCurrentDurationTextId()
/**
* Total time text of the touch progress dialog
* Can be returned by overriding after inheritance, if not, it can be empty
* If there is a custom implementation logic, you can override the showProgressDialog method
*/
protected int getProgressDialogAllDurationTextId()
/**
* image id of the touch progress dialog
* Can be returned by overriding after inheritance, if not, it can be empty
* If there is a custom implementation logic, you can override the showProgressDialog method
*/
protected int getProgressDialogImageId()
/**
* layoutId of the volume dialog
* Can be returned by overriding after inheritance
* If there is a custom implementation logic, you can override the showVolumeDialog method
*/
protected int getVolumeLayoutId()
/**
* percentage progress bar id of the volume dialog
* Can be returned by overriding after inheritance, if not, it can be empty
* If there is a custom implementation logic, you can override the showVolumeDialog method
*/
protected int getVolumeProgressId()
/**
* layoutId of the brightness dialog
* Can be returned by overriding after inheritance
* If there is a custom implementation logic, you can override the showBrightnessDialog method
*/
protected int getBrightnessLayoutId()
/**
* percentage text id of the brightness dialog
* Can be returned by overriding after inheritance, if not, it can be empty
* If there is a custom implementation logic, you can override the showBrightnessDialog method
*/
protected int getBrightnessTextId()
/**
* Progress callback
*/
public void setGSYVideoProgressListener(GSYVideoProgressListener videoProgressListener)
Commented in DetailFilterActivity
//Gaussian stretch video to fill the background, replace black, and play at normal ratio in the foreground
GSYVideoManager.instance().setLogLevel(IjkMediaPlayer.IJK_LOG_SILENT);
1. Global settings
GSYVideoType.setRenderType(GSYVideoType.GLSURFACE);
2. Set filter
player.setEffectFilter(new BarrelBlurEffect());
public void setSpeedPlaying(float speed, boolean soundTouch)
/**
* Get the full-screen player object
*
* @return GSYVideoPlayer returns null if there is none.
*/
public GSYVideoPlayer getFullWindowPlayer()
/**
* Whether to follow the system rotation, if false, it will rotate even if the system prohibits rotation
* @param rotateWithSystem default true
*/
public void setRotateWithSystem(boolean rotateWithSystem)
StandardGSYVideoPlayer.java
/**
* Set the disappearance time of the touch display control UI
* @param dismissControlTime milliseconds, default 2500
*/
public void setDismissControlTime(int dismissControlTime)
/**
* Adjust the ratio of touch sliding fast forward
* @param seekRatio The ratio of sliding fast forward, the default is 1. The larger the value, the smaller the seek generated by sliding
*/
public void setSeekRatio(float seekRatio)
GSYVideoType.java
//Full-screen stretching display, when using this attribute, it is recommended to use FrameLayout for surface_container
public final static int SCREEN_MATCH_FULL = -4;
/**
* Whether to load and display the paused cover image
* When it is on, pause and go to the background, and then return to the foreground without a black screen, but it may cause OOM on some models
* When it is off, pause and go to the background, and then return to the foreground with a black screen
*
* @param showPauseCover default true
*/
public void setShowPauseCover(boolean showPauseCover)
/**
* Set a custom so package loading class
* Needs to be set before instance
*/
public static void setIjkLibLoader(IjkLibLoader libLoader)
/**
* Whether the full-screen sliding interface can change the progress, sound, etc.
* Default true
*/
public void setIsTouchWigetFull(boolean isTouchWigetFull)
/**
* Whether to add an external timeout judgment when buffering, it has no effect on the timeout at the beginning
*
* After the timeout, the onError interface will be called, and the player will call back through onPlayError
*
* The error code is: BUFFER_TIME_OUT_ERROR = -192
*
* Since GSYVideoPlayer's OnError is executed after onError, if you don't want to trigger an error,
* you can override onError and intercept and handle it before super.
*
* public void onError(int what, int extra){
* do you want before super and return;
* super.onError(what, extra)
* }
*
* @param timeOut Timeout time, milliseconds, default 8000
* @param needTimeOutOther Whether to delay the setting, default is off
*/
public void setTimeOut(int timeOut, boolean needTimeOutOther) {
this.timeOut = timeOut;
this.needTimeOutOther = needTimeOutOther;
}
/**
* Set the button resource for switching to full screen in the lower right corner
* Must be set before setUp
* If not set, the default is used
*/
public void setEnlargeImageRes(int mEnlargeImageRes)
/**
* Set the button resource for exiting full screen in the lower right corner
* Must be set before setUp
* If not set, the default is used
*/
public void setShrinkImageRes(int mShrinkImageRes)
/**
* Set the option of IJK video
*/
public void setOptionModelList(List<VideoOptionModel> optionModelList)
Under GSYVideoManager Can refer to: ListNormalAdapter
/**
* Whether to mute
*/
public void setNeedMute(boolean needMute)
/**
* If you need to use: support for using two sets of layouts in full screen and normal playback.
* Then please remember to override the following constructor when overriding the player
*/
public XXXXXXXXXX(Context context, Boolean fullFlag) {
super(context, fullFlag);
}
····
//This must be configured with the above constructor to take effect
@Override
public int getLayoutId() {
if (mIfCurrentIsFullscreen) {
return R.layout.sample_video_land;
}
return R.layout.sample_video;
}
/**
* Whether to display the traffic prompt, the default is true
*/
public void setNeedShowWifiTip(boolean needShowWifiTip)
/**
* If you need to preview the progress bar, set it to on, the default is off
*/
public void setOpenPreView(boolean localFile)
GSYVideoManager
/**
* Set the playback type of the video
* GSYVideoType IJKPLAYER = 0 or IJKEXOPLAYER = 1;
*/
public void setVideoType(Context context, int videoType)
GSYVideoType
/**
* Set display ratio
*/
public static void setShowType(int type)
/**
* Enable hard decoding, set before playback
*/
public static void enableMediaCodec() {
MEDIA_CODEC_FLAG = true;
}
/**
* Disable hard decoding, set before playback
*/
public static void disableMediaCodec()
StandardGSYVideoPlayer/ListVideoUtil
/**
* Whether to need full-screen lock screen function
* If used alone, please set setIfCurrentIsFullscreen to true
*/
public void setNeedLockFull(boolean needLoadFull)
GSYVideoManager
/**
* Pause playback
*/
public static void onPause()
/**
* Resume playback
*/
public static void onResume()
/**
* Hide virtual buttons in full screen, default is on
*/
public void setHideKey(boolean hideKey)
GSYVideoManager
/**
* Delete all default cache files
*/
public static void clearAllDefaultCache(Context context)
/**
* Delete the default cache file corresponding to the url
*/
public static void clearDefaultCache(Context context, String url)
GSYVideoPlayer
/**
* Clear the current cache
*/
public void clearCurrentCache()
/**
* Where to start playing
* At present, there is a problem of jumping in the first few seconds
*/
public void setSeekOnStart(int seekOnStart)
Normal mode
//Default cache path method
holder.gsyVideoPlayer.setUp(url, true , "");
···
//The video cache path of a list is the same
holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), ""));
···
//If the cache paths in a list are different, you need to use the following method
//To avoid being unavailable when returning from full screen, only initialize the UI that is not at the current position
if (playPosition < 0 || playPosition != position ||
!GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)) {
holder.gsyVideoPlayer.initUIState();
}
//If you set that you can play by clicking the cover, if the cache list path is inconsistent, you also need to set the cover click
holder.gsyVideoPlayer.setThumbPlay(true);
holder.gsyVideoPlayer.getStartButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Need to switch the cache path
holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), ""));
holder.gsyVideoPlayer.startPlayLogic();
}
});
holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Need to switch the cache path
holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), ""));
holder.gsyVideoPlayer.startPlayLogic();
}
});
ListVideoUtils
public void setCachePath(File cachePath)
public void setObjects(Object[] objects)
public void setMapHeadData(Map<String, String> mapHeadData)
/**
* Network speed
* Note that if caching is enabled here, because the local proxy is read, there is still speed after the cache is successful
* When you open the cached local file again, the network speed will return to 0. Because you are playing a local file
*/
public long getNetSpeed()
/**
* Network speed
* Note that if caching is enabled here, because the local proxy is read, there is still speed after the cache is successful
* When you open the cached local file again, the network speed will return to 0. Because you are playing a local file
*/
public String getNetSpeedText()
/**
* Playback speed
*/
public void setSpeed(float speed)
public void setLooping(boolean looping)
/**
* Full-screen animation
*
* @param showFullAnimation Whether to use full-screen animation effect
*/
public void setShowFullAnimation(boolean showFullAnimation)
/**
* Whether to enable automatic rotation
*/
public void setRotateViewAuto(boolean rotateViewAuto)
/**
* Lock the screen horizontally as soon as it is full screen, the default is false for vertical screen, can be used with setRotateViewAuto
*/
public void setLockLand(boolean lockLand)
/**
* Whether to rotate automatically
*
* @param autoRotation Whether to support gravity rotation
*/
public void setAutoRotation(boolean autoRotation) {
this.autoRotation = autoRotation;
}
/**
* Whether to be horizontal immediately in full screen
*
* @param fullLandFrist If so, it will switch to horizontal screen when in full screen
*/
public void setFullLandFrist(boolean fullLandFrist) {
this.fullLandFrist = fullLandFrist;
}
/**
* Full-screen animation
*
* @param showFullAnimation Whether to use full-screen animation effect
*/
public void setShowFullAnimation(boolean showFullAnimation) {
this.showFullAnimation = showFullAnimation;
}
arm64 and -86_64 are not added, if you need to add them yourself, because the minimum compilation requires API21
android {
···
defaultConfig {
···
ndk {
//Set the supported SO library architecture
abiFilters 'armeabi', 'armeabi-v7a', 'x86'
}
}
listVideoUtil.getDuration()
listVideoUtil.getCurrentPositionWhenPlaying();
GSYVideoPlayer.getDuration()
GSYVideoPlayer.getCurrentPositionWhenPlaying();
//The callback handles the reply page when the small window close is clicked
listVideoUtil.setVideoAllCallBack(new SampleListener(){
@Override
public void onQuitSmallWidget(String url, Object... objects) {
super.onQuitSmallWidget(url, objects);
//Greater than 0 means there is playback, //The corresponding playback list TAG
if (listVideoUtil.getPlayPosition() >= 0 && listVideoUtil.getPlayTAG().equals(ListVideoAdapter.TAG)) {
//The current playback position
int position = listVideoUtil.getPlayPosition();
//When it is not visible
if ((position < firstVisibleItem || position > lastVisibleItem)) {
//Release the video
listVideoUtil.releaseVideoPlayer();
listVideoAdapter.notifyDataSetChanged();
}
}
}
});
Easier to import, reducing useless dependencies, and removing the problem of needing to configure gradle.properties when importing.
There are interface callbacks from full screen to non-full screen, from small window to non-full screen, end playback error touch, etc., added Debuger, which can enable or disable debugging output.
/**
* Bottom progress bar - pop-up
*/
public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb)
/**
* Bottom progress bar - non-pop-up
*/
public void setBottomProgressBarDrawable(Drawable drawable)
/**
* Sound progress bar
*/
public void setDialogVolumeProgressBar(Drawable drawable)
/**
* Middle progress bar
*/
public void setDialogProgressBar(Drawable drawable)
/**
* Middle progress bar font color
*/
public void setDialogProgressColor(int highLightColor, int normalColor)
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastVisibleItem = firstVisibleItem + visibleItemCount;
//Greater than 0 means there is playback, //The corresponding playback list TAG
if (listVideoUtil.getPlayPosition() >= 0 && listVideoUtil.getPlayTAG().equals(ListVideoAdapter.TAG)) {
//The current playback position
int position = listVideoUtil.getPlayPosition();
//When it is not visible
if ((position < firstVisibleItem || position > lastVisibleItem)) {
//If it is a small window, no need to handle it
if (!listVideoUtil.isSmall()) {
//Small window
int size = CommonUtil.dip2px(ListVideo2Activity.this, 150);
listVideoUtil.showSmallVideo(new Point(size, size), false, true);
}
} else {
if (listVideoUtil.isSmall()) {
listVideoUtil.smallVideoToNormal();
}
}
}
}
/**
* Full-screen animation
*
* @param showFullAnimation Whether to use full-screen animation effect
*/
public void setShowFullAnimation(boolean showFullAnimation)
/**
* Whether the sliding interface can change the progress, sound, etc.
*/
public void setIsTouchWiget(boolean isTouchWiget)
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;
//Greater than 0 means there is playback
if (GSYVideoManager.instance().getPlayPosition() >= 0) {
//The current playback position
int position = GSYVideoManager.instance().getPlayPosition();
//The corresponding playback list TAG
if (GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)
&& (position < firstVisibleItem || position > lastVisibleItem)) {
//If it slides out, the top and bottom are no, just like Toutiao
GSYVideoPlayer.releaseAllVideos();
listNormalAdapter.notifyDataSetChanged();
}
}
}
});
····
holder.gsyVideoPlayer.setPlayTag(TAG);
holder.gsyVideoPlayer.setPlayPosition(position);