@Override public void setVideoRotation(int degree) { PLog.e(TAG,"surface view not support rotation ... "); }
@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); } };
value += "," + bundle.toString(); PLog.e(EVENT_TAG_ERROR_EVENT, value);
/** * 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 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(); } }
/** * 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 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 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; } }
@Override public void onErrorEvent(int eventCode, Bundle bundle) { PLog.e(TAG,"onError : code = " + eventCode + ", Message = " + (bundle==null?"no message":bundle.toString())); if(mOnErrorEventListener!=null) mOnErrorEventListener.onErrorEvent(eventCode, bundle); //last dispatch event , because bundle will be recycle after dispatch. mSuperContainer.dispatchErrorEvent(eventCode, bundle); } };
@Override public void stopPlayback() { PLog.e(TAG,"stopPlayback release."); releaseAudioFocus(); mPlayer.destroy(); mRenderHolder = null; releaseRender(); mSuperContainer.destroy(); }
private void attachTimedTextSource() { TimedTextSource timedTextSource = mDataSource.getTimedTextSource(); if(timedTextSource==null) return; try{ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ mMediaPlayer.addTimedTextSource(timedTextSource.getPath(), timedTextSource.getMimeType()); MediaPlayer.TrackInfo[] trackInfos = mMediaPlayer.getTrackInfo(); if (trackInfos != null && trackInfos.length > 0){ for (int i = 0; i < trackInfos.length; i++){ final MediaPlayer.TrackInfo info = trackInfos[i]; if (info.getTrackType() == MediaPlayer.TrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT){ mMediaPlayer.selectTrack(i); break; } } } }else{ PLog.e(TAG,"not support setting timed text source !"); } }catch (Exception e){ PLog.e(TAG,"addTimedTextSource error !"); e.printStackTrace(); } }
@Override public void setSpeed(float speed) { try { if(available() && Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ PlaybackParams playbackParams = mMediaPlayer.getPlaybackParams(); playbackParams.setSpeed(speed); /** * Sets playback rate using {@link PlaybackParams}. The object sets its internal * PlaybackParams to the input, except that the object remembers previous speed * when input speed is zero. This allows the object to resume at previous speed * when start() is called. Calling it before the object is prepared does not change * the object state. After the object is prepared, calling it with zero speed is * equivalent to calling pause(). After the object is prepared, calling it with * non-zero speed is equivalent to calling start(). */ mMediaPlayer.setPlaybackParams(playbackParams); if(speed <= 0){ pause(); }else if(speed > 0 && getState()==STATE_PAUSED){ resume(); } }else{ PLog.e(TAG,"not support play speed setting."); } }catch (Exception e){ PLog.e(TAG,"IllegalStateException, if the internal player engine has not been initialized " + "or has been released."); } }
@Override public void run() { ListAdapter.VideoItemHolder currentHolder = mListAdapter.getCurrentHolder(); if(currentHolder!=null){ ListPlayer.get().setReceiverConfigState(getActivity(), ISPayer.RECEIVER_GROUP_CONFIG_LIST_STATE); ListPlayer.get().attachContainer(currentHolder.layoutContainer, false); }else{ PLog.e("VideoListFragment", "portrait itemHolder null"); } } });
PLog.e(TAG,"ijkplayer not support timed text !");