@Override public void onSurfaceDestroy(IRender.IRenderHolder renderHolder) { PLog.d(TAG,"onSurfaceDestroy..."); //on surface destroy detach player mRenderHolder = null; } };
@Override public void setVideoRotation(int degree) { PLog.e(TAG,"surface view not support rotation ... "); }
public synchronized static Bundle obtain(){ for(int i=0;i<POOL_SIZE;i++){ if(mPool.get(i).isEmpty()){ return mPool.get(i); } } PLog.w("BundlePool","<create new bundle object>"); return new Bundle(); }
@Override public void onRenderedFirstFrame() { PLog.d(TAG,"onRenderedFirstFrame"); updateStatus(IPlayer.STATE_STARTED); submitPlayerEvent(OnPlayerEventListener.PLAYER_EVENT_ON_VIDEO_RENDER_START, null); } };
private void detachReceiver(IReceiver receiver){ if(receiver instanceof BaseCover){ BaseCover cover = (BaseCover) receiver; //remove cover view to cover strategy container. mCoverStrategy.removeCover(cover); PLog.w(TAG, "on cover detach : " + cover.getTag() + " ," + cover.getCoverLevel()); } //unbind the ReceiverEventListener for receivers connect. receiver.bindReceiverEventListener(null); receiver.bindStateGetter(null); }
public void setVideoSize(int videoWidth, int videoHeight){ PLog.d(TAG,"videoWidth = " + videoWidth + " videoHeight = " + videoHeight); this.mVideoWidth = videoWidth; this.mVideoHeight = videoHeight; }
@Override public void onProviderError(int code, Bundle bundle) { PLog.e(TAG,"onProviderError : code = " + code + ", bundle = " + bundle); if(mOnProviderListener!=null) mOnProviderListener.onProviderError(code, bundle); //need recreate a new bundle, because a bundle will be recycle after call back. Bundle errorBundle; if(bundle!=null){ errorBundle = new Bundle(bundle); }else{ errorBundle = new Bundle(); } errorBundle.putInt(EventKey.INT_DATA,code); //call back player event callBackPlayEventListener(code, bundle); //call back error event callBackErrorEventListener( OnErrorEventListener.ERROR_EVENT_DATA_PROVIDER_ERROR,errorBundle); } };
@Override public void onSurfaceDestroy(IRender.IRenderHolder renderHolder) { PLog.d(TAG,"onSurfaceDestroy..."); //on surface destroy detach player mRenderHolder = null; } };
value += "," + bundle.toString(); PLog.e(EVENT_TAG_ERROR_EVENT, value);
@Override public void onSurfaceCreated(IRender.IRenderHolder renderHolder, int width, int height) { PLog.d(TAG,"onSurfaceCreated : width = " + width + ", height = " + height); //on surface create ,try to attach player. mRenderHolder = renderHolder; bindRenderHolder(mRenderHolder); } @Override
/** * Send an event to the specified receiver, * make sure that the key value you imported is correct. * * @param key The unique value of a receiver can be found. * @param eventCode * @param bundle * * @return Bundle Return value after the receiver's response, nullable. * */ protected final @Nullable Bundle notifyReceiverPrivateEvent( @NonNull String key, int eventCode, Bundle bundle){ if(mHostGroup!=null && !TextUtils.isEmpty(key)){ IReceiver receiver = mHostGroup.getReceiver(key); if(receiver!=null){ return receiver.onPrivateEvent(eventCode, bundle); }else{ PLog.e("BaseReceiver", "not found receiver use you incoming key."); } } return null; }
@Override public void onSurfaceCreated(IRender.IRenderHolder renderHolder, int width, int height) { PLog.d(TAG,"onSurfaceCreated : width = " + width + ", height = " + height); //on surface create ,try to attach player. mRenderHolder = renderHolder; bindRenderHolder(mRenderHolder); } @Override
@Override public void requestPlayDataSource(BaseVideoView assist, Bundle bundle) { if(bundle!=null){ DataSource data = (DataSource) bundle.getSerializable(EventKey.SERIALIZABLE_DATA); if(data==null){ PLog.e("OnVideoViewEventHandler","requestPlayDataSource need legal data source"); return; } assist.stop(); assist.setDataSource(data); assist.start(); } }
@Override public void onSeekComplete(IMediaPlayer mp) { PLog.d(TAG,"EVENT_CODE_SEEK_COMPLETE"); submitPlayerEvent(OnPlayerEventListener.PLAYER_EVENT_ON_SEEK_COMPLETE,null); } };
/** * With this method, you can switch the decoding plan, * this call will be recreate internal player instance. * and the subsequent operations after switching must be processed by yourself, * such as resetting the data to play and so on. * after switch, if you want get current planId, * you can get it by {@link PlayerConfig#getDefaultPlanId()} * * @param decoderPlanId the planId is your configuration ids or default id. * @return Whether or not to switch to success. * if return false, maybe your incoming planId is the same as the current planId * or your incoming planId is illegal param. * return true is switch decoder success. * */ public boolean switchDecoder(int decoderPlanId){ if(mDecoderPlanId == decoderPlanId){ PLog.e(this.getClass().getSimpleName(), "@@Your incoming planId is the same as the current use planId@@"); return false; } if(PlayerConfig.isLegalPlanId(decoderPlanId)){ //and reload internal player instance. loadInternalPlayer(decoderPlanId); return true; }else{ throw new IllegalArgumentException("Illegal plan id = " + decoderPlanId + ", please check your config!"); } }
@Override protected void onCoversRemoveAll() { PLog.d(TAG,"on covers remove all ..."); }
@Override public void requestPlayDataSource(AssistPlay assist, Bundle bundle) { if(bundle!=null){ DataSource data = (DataSource) bundle.getSerializable(EventKey.SERIALIZABLE_DATA); if(data==null){ PLog.e("OnAssistPlayEventHandler","requestPlayDataSource need legal data source"); return; } assist.stop(); assist.setDataSource(data); assist.play(); } } }
@Override public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { PLog.d(TAG,"onPlaybackParametersChanged : " + playbackParameters.toString()); } };
@Override public void onPlayerError(ExoPlaybackException error) { if(error==null){ submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null); return; } PLog.e(TAG,error.getMessage()==null?"":error.getMessage()); int type = error.type; switch (type){ case ExoPlaybackException.TYPE_SOURCE: submitErrorEvent(OnErrorEventListener.ERROR_EVENT_IO, null); break; case ExoPlaybackException.TYPE_RENDERER: submitErrorEvent(OnErrorEventListener.ERROR_EVENT_COMMON, null); break; case ExoPlaybackException.TYPE_UNEXPECTED: submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null); break; } }