提交 f626ddfc authored 作者: kongdywang's avatar kongdywang

1. Fix file name conflict issues in some cases

2. Add setSDKListener in SuperPlayerPlugin 3. Fix android pip start-up failed in sdk 11.7
上级 28911c12
......@@ -23,7 +23,7 @@
</intent-filter>
</activity>
<service android:name="com.tencent.vod.flutter.ui.Android12BridgeService"/>
<service android:name="com.tencent.vod.flutter.ui.TXAndroid12BridgeService"/>
</application>
</manifest>
\ No newline at end of file
......@@ -24,7 +24,7 @@ import com.tencent.vod.flutter.messages.FtxMessages.PreLoadMsg;
import com.tencent.vod.flutter.messages.FtxMessages.TXDownloadListMsg;
import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterDownloadApi;
import com.tencent.vod.flutter.messages.FtxMessages.TXVodDownloadMediaMsg;
import com.tencent.vod.flutter.tools.CommonUtil;
import com.tencent.vod.flutter.tools.TXCommonUtil;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.EventChannel;
......@@ -83,8 +83,8 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
bundle.putInt("taskId", taskId);
bundle.putString("fileId", fileId);
bundle.putString("url", url);
Map<String, Object> result = CommonUtil.getParams(FTXEvent.EVENT_PREDOWNLOAD_ON_START, bundle);
result.put("params", CommonUtil.transToMap(params));
Map<String, Object> result = TXCommonUtil.getParams(FTXEvent.EVENT_PREDOWNLOAD_ON_START, bundle);
result.put("params", TXCommonUtil.transToMap(params));
sendSuccessEvent(result);
}
......@@ -92,7 +92,7 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
Bundle bundle = new Bundle();
bundle.putInt("taskId", taskId);
bundle.putString("url", url);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_PREDOWNLOAD_ON_COMPLETE, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_PREDOWNLOAD_ON_COMPLETE, bundle));
}
private void onErrorEvent(long tmpTaskId, int taskId, String url, int code, String msg) {
......@@ -104,7 +104,7 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
bundle.putInt("code", code);
bundle.putString("url", url);
bundle.putString("msg", msg);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_PREDOWNLOAD_ON_ERROR, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_PREDOWNLOAD_ON_ERROR, bundle));
}
private void sendSuccessEvent(final Object event) {
......@@ -126,7 +126,7 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
TXVodDownloadMediaMsg msg = new TXVodDownloadMediaMsg();
if (null != mediaInfo) {
msg.setPlayPath(mediaInfo.getPlayPath());
msg.setDownloadState((long) CommonUtil.getDownloadEventByState(mediaInfo.getDownloadState()));
msg.setDownloadState((long) TXCommonUtil.getDownloadEventByState(mediaInfo.getDownloadState()));
msg.setUserName(mediaInfo.getUserName());
msg.setDuration((long) mediaInfo.getDuration());
msg.setPlayableDuration((long) mediaInfo.getPlayableDuration());
......@@ -166,7 +166,7 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
Bundle bundle = new Bundle();
bundle.putString("playPath", mediaInfo.getPlayPath());
bundle.putFloat("progress", mediaInfo.getProgress());
bundle.putInt("downloadState", CommonUtil.getDownloadEventByState(mediaInfo.getDownloadState()));
bundle.putInt("downloadState", TXCommonUtil.getDownloadEventByState(mediaInfo.getDownloadState()));
bundle.putString("userName", mediaInfo.getUserName());
bundle.putInt("duration", mediaInfo.getDuration());
bundle.putInt("playableDuration", mediaInfo.getPlayableDuration());
......@@ -239,26 +239,26 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
@Override
public void onDownloadStart(TXVodDownloadMediaInfo txVodDownloadMediaInfo) {
Bundle bundle = buildCommonDownloadBundle(txVodDownloadMediaInfo);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_START, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_START, bundle));
}
@Override
public void onDownloadProgress(TXVodDownloadMediaInfo txVodDownloadMediaInfo) {
Bundle bundle = buildCommonDownloadBundle(txVodDownloadMediaInfo);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_PROGRESS, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_PROGRESS, bundle));
}
@Override
public void onDownloadStop(TXVodDownloadMediaInfo txVodDownloadMediaInfo) {
Bundle bundle = buildCommonDownloadBundle(txVodDownloadMediaInfo);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_STOP, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_STOP, bundle));
}
@Override
public void onDownloadFinish(TXVodDownloadMediaInfo txVodDownloadMediaInfo) {
Bundle bundle = buildCommonDownloadBundle(txVodDownloadMediaInfo);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_FINISH, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_FINISH, bundle));
}
@Override
......@@ -266,7 +266,7 @@ public class FTXDownloadManager implements ITXVodDownloadListener, TXFlutterDown
Bundle bundle = buildCommonDownloadBundle(txVodDownloadMediaInfo);
bundle.putInt("errorCode", i);
bundle.putString("errorMsg", s);
sendSuccessEvent(CommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_ERROR, bundle));
sendSuccessEvent(TXCommonUtil.getParams(FTXEvent.EVENT_DOWNLOAD_ERROR, bundle));
}
/**
......
......@@ -159,4 +159,26 @@ public class FTXEvent {
// 横屏,底部在左
public static final int ORIENTATION_LANDSCAPE_LEFT = 414;
// SDK event
// onLog
public static final int EVENT_ON_LOG = 501;
// onUpdateNetworkTime
public static final int EVENT_ON_UPDATE_NETWORK_TIME = 502;
// onLicenceLoaded
public static final int EVENT_ON_LICENCE_LOADED = 503;
// onCustomHttpDNS
public static final int EVENT_ON_CUSTOM_HTTP_DNS = 504;
// this events may be common,so remove the specific field identifier
public static final String EVENT_LOG_LEVEL = "logLevel";
public static final String EVENT_LOG_MODULE = "logModule";
public static final String EVENT_LOG_MSG = "logMsg";
public static final String EVENT_ERR_CODE = "errCode";
public static final String EVENT_ERR_MSG = "errMsg";
public static final String EVENT_RESULT = "result";
public static final String EVENT_REASON = "reason";
public static final String EVENT_HOST_NAME = "hostName";
public static final String EVENT_IPS = "ips";
}
......@@ -15,7 +15,6 @@ import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.TXVodConstants;
import com.tencent.vod.flutter.messages.FtxMessages.BoolMsg;
import com.tencent.vod.flutter.messages.FtxMessages.BoolPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.DoublePlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.FTXLivePlayConfigPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.IntMsg;
import com.tencent.vod.flutter.messages.FtxMessages.IntPlayerMsg;
......@@ -24,9 +23,9 @@ import com.tencent.vod.flutter.messages.FtxMessages.PlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringIntPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterLivePlayerApi;
import com.tencent.vod.flutter.model.PipResult;
import com.tencent.vod.flutter.model.VideoModel;
import com.tencent.vod.flutter.tools.CommonUtil;
import com.tencent.vod.flutter.model.TXPipResult;
import com.tencent.vod.flutter.model.TXVideoModel;
import com.tencent.vod.flutter.tools.TXCommonUtil;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.EventChannel;
......@@ -60,10 +59,10 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
private final FTXPIPManager mPipManager;
private FTXPIPManager.PipParams mPipParams;
private VideoModel mVideoModel;
private TXVideoModel mVideoModel;
private final FTXPIPManager.PipCallback pipCallback = new FTXPIPManager.PipCallback() {
@Override
public void onPipResult(PipResult result) {
public void onPipResult(TXPipResult result) {
// When starting PIP, if the current player is paused and PIP is still playing when exiting,
// the current player will also be set to playing state upon exiting PIP.
boolean isPipPlaying = result.isPlaying();
......@@ -82,7 +81,7 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
super();
mFlutterPluginBinding = flutterPluginBinding;
mPipManager = pipManager;
mVideoModel = new VideoModel();
mVideoModel = new TXVideoModel();
mVideoModel.setPlayerType(FTXEvent.PLAYER_LIVE);
mSurfaceTextureEntry = mFlutterPluginBinding.getTextureRegistry().createSurfaceTexture();
......@@ -158,12 +157,12 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
if (event != TXVodConstants.VOD_PLAY_EVT_PLAY_PROGRESS) {
Log.e(TAG, "onLivePlayEvent:" + event + "," + bundle.getString(TXLiveConstants.EVT_DESCRIPTION));
}
mEventSink.success(CommonUtil.getParams(event, bundle));
mEventSink.success(TXCommonUtil.getParams(event, bundle));
}
@Override
public void onNetStatus(Bundle bundle) {
mNetStatusSink.success(CommonUtil.getParams(0, bundle));
mNetStatusSink.success(TXCommonUtil.getParams(0, bundle));
}
// The default size of the surface is 1x1. When hardware decoding fails or software decoding is used,
......@@ -338,7 +337,7 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
@Override
public IntMsg initialize(@NonNull BoolPlayerMsg onlyAudio) {
long textureId = init(onlyAudio.getValue() != null ? onlyAudio.getValue() : false);
return CommonUtil.intMsgWith(textureId);
return TXCommonUtil.intMsgWith(textureId);
}
@NonNull
......@@ -346,20 +345,20 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
public BoolMsg startLivePlay(@NonNull StringIntPlayerMsg playerMsg) {
int r = startPlayerLivePlay(playerMsg.getStrValue(),
null != playerMsg.getIntValue() ? playerMsg.getIntValue().intValue() : null);
return CommonUtil.boolMsgWith(r == 1);
return TXCommonUtil.boolMsgWith(r == 1);
}
@NonNull
@Override
public BoolMsg stop(@NonNull BoolPlayerMsg isNeedClear) {
boolean flag = null != isNeedClear.getValue() ? isNeedClear.getValue() : false;
return CommonUtil.boolMsgWith(stopPlay(flag) == 1);
return TXCommonUtil.boolMsgWith(stopPlay(flag) == 1);
}
@NonNull
@Override
public BoolMsg isPlaying(@NonNull PlayerMsg playerMsg) {
return CommonUtil.boolMsgWith(isPlayerPlaying());
return TXCommonUtil.boolMsgWith(isPlayerPlaying());
}
@Override
......@@ -396,7 +395,7 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
@NonNull
@Override
public IntMsg switchStream(@NonNull StringPlayerMsg url) {
return CommonUtil.intMsgWith((long) switchPlayerStream(url.getValue()));
return TXCommonUtil.intMsgWith((long) switchPlayerStream(url.getValue()));
}
@Override
......@@ -415,9 +414,9 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
@Override
public BoolMsg enableHardwareDecode(@NonNull BoolPlayerMsg enable) {
if (null != enable.getValue()) {
return CommonUtil.boolMsgWith(enablePlayerHardwareDecode(enable.getValue()));
return TXCommonUtil.boolMsgWith(enablePlayerHardwareDecode(enable.getValue()));
}
return CommonUtil.boolMsgWith(false);
return TXCommonUtil.boolMsgWith(false);
}
@NonNull
......@@ -436,7 +435,7 @@ public class FTXLivePlayer extends FTXBasePlayer implements ITXLivePlayListener,
if (pipResult == FTXEvent.NO_ERROR) {
pausePlayer();
}
return CommonUtil.intMsgWith((long) pipResult);
return TXCommonUtil.intMsgWith((long) pipResult);
}
@Override
......
......@@ -26,9 +26,9 @@ import android.util.Log;
import android.util.Rational;
import androidx.annotation.RequiresApi;
import com.tencent.vod.flutter.model.PipResult;
import com.tencent.vod.flutter.model.VideoModel;
import com.tencent.vod.flutter.tools.CommonUtil;
import com.tencent.vod.flutter.model.TXPipResult;
import com.tencent.vod.flutter.model.TXVideoModel;
import com.tencent.vod.flutter.tools.TXCommonUtil;
import com.tencent.vod.flutter.ui.FlutterPipImplActivity;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding;
......@@ -69,13 +69,13 @@ public class FTXPIPManager {
Bundle data = intent.getExtras();
if ((pipEventId == FTXEvent.EVENT_PIP_MODE_ALREADY_EXIT
|| pipEventId == FTXEvent.EVENT_PIP_MODE_RESTORE_UI) && null != data) {
PipResult pipResult = data.getParcelable(FTXEvent.EXTRA_NAME_RESULT);
TXPipResult pipResult = data.getParcelable(FTXEvent.EXTRA_NAME_RESULT);
if (null != pipResult) {
callbackData.putDouble(FTXEvent.EVENT_PIP_PLAY_TIME, pipResult.getPlayTime());
handlePipResult(pipResult);
}
}
mPipEventSink.success(CommonUtil.getParams(pipEventId, callbackData));
mPipEventSink.success(TXCommonUtil.getParams(pipEventId, callbackData));
}
}
};
......@@ -132,7 +132,7 @@ public class FTXPIPManager {
}
}
private void handlePipResult(PipResult result) {
private void handlePipResult(TXPipResult result) {
PipCallback pipCallback = pipCallbacks.get(result.getPlayerId());
if (null != pipCallback) {
pipCallback.onPipResult(result);
......@@ -146,10 +146,10 @@ public class FTXPIPManager {
*
* @return {@link FTXEvent} ERROR_PIP
*/
public int enterPip(PipParams params, VideoModel videoModel) {
public int enterPip(PipParams params, TXVideoModel videoModel) {
int pipResult = isSupportDevice();
if (pipResult == FTXEvent.NO_ERROR) {
mPipEventSink.success(CommonUtil.getParams(FTXEvent.EVENT_PIP_MODE_REQUEST_START, null));
mPipEventSink.success(TXCommonUtil.getParams(FTXEvent.EVENT_PIP_MODE_REQUEST_START, null));
Intent intent = new Intent(mActivityBinding.getActivity(), FlutterPipImplActivity.class);
intent.setAction(FTXEvent.PIP_ACTION_START);
intent.putExtra(FTXEvent.EXTRA_NAME_PARAMS, params);
......@@ -501,6 +501,6 @@ public class FTXPIPManager {
* Close PIP.
* pip关闭
*/
void onPipResult(PipResult result);
void onPipResult(TXPipResult result);
}
}
......@@ -32,9 +32,9 @@ import com.tencent.vod.flutter.messages.FtxMessages.StringListPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.TXPlayInfoParamsPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.UInt8ListMsg;
import com.tencent.vod.flutter.model.PipResult;
import com.tencent.vod.flutter.model.VideoModel;
import com.tencent.vod.flutter.tools.CommonUtil;
import com.tencent.vod.flutter.model.TXPipResult;
import com.tencent.vod.flutter.model.TXVideoModel;
import com.tencent.vod.flutter.tools.TXCommonUtil;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.EventChannel;
......@@ -67,7 +67,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
private TXVodPlayer mVodPlayer;
private TXImageSprite mTxImageSprite;
private VideoModel mVideoModel;
private TXVideoModel mVideoModel;
private static final int Uninitialized = -101;
private TextureRegistry.SurfaceTextureEntry mSurfaceTextureEntry;
......@@ -78,7 +78,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
private FTXPIPManager.PipParams mPipParams;
private final FTXPIPManager.PipCallback pipCallback = new FTXPIPManager.PipCallback() {
@Override
public void onPipResult(PipResult result) {
public void onPipResult(TXPipResult result) {
float playTime = result.getPlayTime();
float duration = mVodPlayer.getDuration();
if (playTime > duration) {
......@@ -103,7 +103,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
super();
mPipManager = pipManager;
mFlutterPluginBinding = flutterPluginBinding;
mVideoModel = new VideoModel();
mVideoModel = new TXVideoModel();
mVideoModel.setPlayerType(FTXEvent.PLAYER_VOD);
mEventChannel = new EventChannel(flutterPluginBinding.getBinaryMessenger(), "cloud.tencent"
......@@ -185,7 +185,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
bundle.putInt("videoTop", videoTop);
bundle.putInt("videoRight", videoRight);
bundle.putInt("videoBottom", videoBottom);
mEventSink.success(CommonUtil.getParams(event, bundle));
mEventSink.success(TXCommonUtil.getParams(event, bundle));
return;
}
}
......@@ -203,7 +203,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
if (event != TXVodConstants.VOD_PLAY_EVT_PLAY_PROGRESS) {
Log.e(TAG, "onPlayEvent:" + event + "," + bundle.getString(TXLiveConstants.EVT_DESCRIPTION));
}
mEventSink.success(CommonUtil.getParams(event, bundle));
mEventSink.success(TXCommonUtil.getParams(event, bundle));
}
// The default size of the surface is 1x1. When hardware decoding fails or software decoding is used,
......@@ -220,7 +220,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@Override
public void onNetStatus(TXVodPlayer txVodPlayer, Bundle bundle) {
mNetStatusSink.success(CommonUtil.getParams(0, bundle));
mNetStatusSink.success(TXCommonUtil.getParams(0, bundle));
}
private byte[] getPlayerImageSprite(final Double time) {
......@@ -470,14 +470,14 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@Override
public IntMsg initialize(@NonNull BoolPlayerMsg onlyAudio) {
long textureId = init(onlyAudio.getValue() != null ? onlyAudio.getValue() : false);
return CommonUtil.intMsgWith(textureId);
return TXCommonUtil.intMsgWith(textureId);
}
@NonNull
@Override
public BoolMsg startVodPlay(@NonNull StringPlayerMsg url) {
String urlStr = url.getValue();
return CommonUtil.boolMsgWith(startPlayerVodPlay(urlStr) == 1);
return TXCommonUtil.boolMsgWith(startPlayerVodPlay(urlStr) == 1);
}
@Override
......@@ -499,13 +499,13 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@Override
public BoolMsg stop(@NonNull BoolPlayerMsg isNeedClear) {
boolean flag = null != isNeedClear.getValue() ? isNeedClear.getValue() : false;
return CommonUtil.boolMsgWith(stopPlay(flag) == 1);
return TXCommonUtil.boolMsgWith(stopPlay(flag) == 1);
}
@NonNull
@Override
public BoolMsg isPlaying(@NonNull PlayerMsg playerMsg) {
return CommonUtil.boolMsgWith(isPlayerPlaying());
return TXCommonUtil.boolMsgWith(isPlayerPlaying());
}
@Override
......@@ -550,13 +550,13 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@Override
public ListMsg getSupportedBitrate(@NonNull PlayerMsg playerMsg) {
//noinspection unchecked
return CommonUtil.listMsgWith((List<Object>) getPlayerSupportedBitrates());
return TXCommonUtil.listMsgWith((List<Object>) getPlayerSupportedBitrates());
}
@NonNull
@Override
public IntMsg getBitrateIndex(@NonNull PlayerMsg playerMsg) {
return CommonUtil.intMsgWith((long) getPlayerBitrateIndex());
return TXCommonUtil.intMsgWith((long) getPlayerBitrateIndex());
}
@Override
......@@ -584,9 +584,9 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@Override
public BoolMsg setRequestAudioFocus(@NonNull BoolPlayerMsg focus) {
if (null != focus.getValue()) {
return CommonUtil.boolMsgWith(requestPlayerAudioFocus(focus.getValue()));
return TXCommonUtil.boolMsgWith(requestPlayerAudioFocus(focus.getValue()));
}
return CommonUtil.boolMsgWith(false);
return TXCommonUtil.boolMsgWith(false);
}
@Override
......@@ -600,7 +600,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
// Use BigDecimal for conversion to prevent precision issues with decimal
// digits when converting from float to double.
BigDecimal bigDecimal = BigDecimal.valueOf(getPlayerCurrentPlaybackTime());
return CommonUtil.doubleMsgWith(bigDecimal.doubleValue());
return TXCommonUtil.doubleMsgWith(bigDecimal.doubleValue());
}
@NonNull
......@@ -609,7 +609,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
// Use BigDecimal for conversion to prevent precision issues with decimal
// digits when converting from float to double.
BigDecimal bigDecimal = BigDecimal.valueOf(getPlayerBufferDuration());
return CommonUtil.doubleMsgWith(bigDecimal.doubleValue());
return TXCommonUtil.doubleMsgWith(bigDecimal.doubleValue());
}
@NonNull
......@@ -618,19 +618,19 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
// Use BigDecimal for conversion to prevent precision issues with decimal
// digits when converting from float to double.
BigDecimal bigDecimal = BigDecimal.valueOf(getPlayerPlayableDuration());
return CommonUtil.doubleMsgWith(bigDecimal.doubleValue());
return TXCommonUtil.doubleMsgWith(bigDecimal.doubleValue());
}
@NonNull
@Override
public IntMsg getWidth(@NonNull PlayerMsg playerMsg) {
return CommonUtil.intMsgWith((long) getPlayerWidth());
return TXCommonUtil.intMsgWith((long) getPlayerWidth());
}
@NonNull
@Override
public IntMsg getHeight(@NonNull PlayerMsg playerMsg) {
return CommonUtil.intMsgWith((long) getPlayerHeight());
return TXCommonUtil.intMsgWith((long) getPlayerHeight());
}
@Override
......@@ -641,16 +641,16 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@NonNull
@Override
public BoolMsg isLoop(@NonNull PlayerMsg playerMsg) {
return CommonUtil.boolMsgWith(isVodPlayerLoop());
return TXCommonUtil.boolMsgWith(isVodPlayerLoop());
}
@NonNull
@Override
public BoolMsg enableHardwareDecode(@NonNull BoolPlayerMsg enable) {
if (null != enable.getValue()) {
return CommonUtil.boolMsgWith(enablePlayerHardwareDecode(enable.getValue()));
return TXCommonUtil.boolMsgWith(enablePlayerHardwareDecode(enable.getValue()));
}
return CommonUtil.boolMsgWith(false);
return TXCommonUtil.boolMsgWith(false);
}
@NonNull
......@@ -673,7 +673,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
if (pipResult == FTXEvent.NO_ERROR) {
playerPause();
}
return CommonUtil.intMsgWith((long) pipResult);
return TXCommonUtil.intMsgWith((long) pipResult);
}
@Override
......@@ -692,9 +692,9 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
@Override
public UInt8ListMsg getImageSprite(@NonNull DoublePlayerMsg time) {
if (null != time.getValue()) {
return CommonUtil.uInt8ListMsg(getPlayerImageSprite(time.getValue()));
return TXCommonUtil.uInt8ListMsg(getPlayerImageSprite(time.getValue()));
}
return CommonUtil.uInt8ListMsg(new byte[0]);
return TXCommonUtil.uInt8ListMsg(new byte[0]);
}
@NonNull
......@@ -704,8 +704,8 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
// Use BigDecimal for conversion to prevent precision issues with decimal
// digits when converting from float to double.
BigDecimal bigDecimal = BigDecimal.valueOf(mVodPlayer.getDuration());
return CommonUtil.doubleMsgWith(bigDecimal.doubleValue());
return TXCommonUtil.doubleMsgWith(bigDecimal.doubleValue());
}
return CommonUtil.doubleMsgWith(0D);
return TXCommonUtil.doubleMsgWith(0D);
}
}
......@@ -25,6 +25,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.tencent.rtmp.TXLiveBase;
import com.tencent.rtmp.TXLiveBaseListener;
import com.tencent.rtmp.TXPlayerGlobalSetting;
import com.tencent.vod.flutter.messages.FTXLivePlayerDispatcher;
import com.tencent.vod.flutter.messages.FTXVodPlayerDispatcher;
......@@ -38,14 +39,16 @@ import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterLivePlayerApi;
import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterNativeAPI;
import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterSuperPlayerPluginAPI;
import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterVodPlayerApi;
import com.tencent.vod.flutter.tools.CommonUtil;
import com.tencent.vod.flutter.tools.TXCommonUtil;
import com.tencent.vod.flutter.tools.TXFlutterEngineHolder;
import com.tencent.vod.flutter.ui.Android12BridgeService;
import com.tencent.vod.flutter.ui.TXAndroid12BridgeService;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -84,8 +87,8 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
private OrientationEventListener mOrientationManager;
private int mCurrentOrientation = FTXEvent.ORIENTATION_PORTRAIT_UP;
private final TXFlutterEngineHolder mEngineHolder = new TXFlutterEngineHolder();
private boolean mIsBrightnessObserverRegistered = false;
private Handler mMainHandler = new Handler(Looper.getMainLooper());
private final FTXAudioManager.AudioFocusChangeListener audioFocusChangeListener =
new FTXAudioManager.AudioFocusChangeListener() {
......@@ -108,6 +111,70 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
}
};
private final TXLiveBaseListener mSDKEvent = new TXLiveBaseListener() {
@Override
public void onLog(int level, String module, String log) {
super.onLog(level, module, log);
// mMainHandler.post(new Runnable() {
// @Override
// public void run() {
// Bundle params = new Bundle();
// params.putInt(FTXEvent.EVENT_LOG_LEVEL, level);
// params.putString(FTXEvent.EVENT_LOG_MODULE, module);
// params.putString(FTXEvent.EVENT_LOG_MSG, log);
// mEventSink.success(getParams(FTXEvent.EVENT_ON_LOG, params));
// }
// });
// this may be too busy, so currently do not throw on the Flutter side
}
@Override
public void onUpdateNetworkTime(int errCode, String errMsg) {
super.onUpdateNetworkTime(errCode, errMsg);
// mMainHandler.post(new Runnable() {
// @Override
// public void run() {
// Bundle params = new Bundle();
// params.putInt(FTXEvent.EVENT_ERR_CODE, errCode);
// params.putString(FTXEvent.EVENT_ERR_MSG, errMsg);
// mEventSink.success(getParams(FTXEvent.EVENT_ON_UPDATE_NETWORK_TIME, params));
// }
// });
// This will be opened in a subsequent version
}
@Override
public void onLicenceLoaded(int result, String reason) {
super.onLicenceLoaded(result, reason);
mMainHandler.post(new Runnable() {
@Override
public void run() {
Bundle params = new Bundle();
params.putInt(FTXEvent.EVENT_RESULT, result);
params.putString(FTXEvent.EVENT_REASON, reason);
mEventSink.success(getParams(FTXEvent.EVENT_ON_LICENCE_LOADED, params));
}
});
}
@Override
public void onCustomHttpDNS(String hostName, List<String> ipList) {
super.onCustomHttpDNS(hostName, ipList);
// mMainHandler.post(new Runnable() {
// @Override
// public void run() {
// Bundle params = new Bundle();
// params.putString(FTXEvent.EVENT_HOST_NAME, hostName);
// ArrayList<String> ipArrayList = new ArrayList<>(ipList);
// params.putStringArrayList(FTXEvent.EVENT_IPS, ipArrayList);
// mEventSink.success(getParams(FTXEvent.EVENT_ON_CUSTOM_HTTP_DNS, params));
// }
// });
// This will be opened in a subsequent version
}
};
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
Log.i(TAG, "onAttachedToEngine");
......@@ -346,7 +413,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
if (null != mActivityPluginBinding && !mActivityPluginBinding.getActivity().isDestroyed()) {
ContentResolver resolver = mActivityPluginBinding.getActivity().getContentResolver();
final int brightnessInt = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS);
final float maxBrightness = CommonUtil.getBrightnessMax();
final float maxBrightness = TXCommonUtil.getBrightnessMax();
screenBrightness = brightnessInt / maxBrightness;
}
} catch (SettingNotFoundException e) {
......@@ -390,6 +457,8 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
initPipManagerIfNeed();
registerReceiver();
mEngineHolder.attachBindLife(binding);
TXLiveBase.enableCustomHttpDNS(true);
TXLiveBase.setListener(mSDKEvent);
}
@Override
......@@ -408,10 +477,11 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
// Close the solution to the problem of the picture-in-picture click restore
// failure on some versions of Android 12.
// 关闭用于解决Android12部分版本上画中画点击还原失灵的问题
Intent serviceIntent = new Intent(mActivityPluginBinding.getActivity(), Android12BridgeService.class);
Intent serviceIntent = new Intent(mActivityPluginBinding.getActivity(), TXAndroid12BridgeService.class);
mActivityPluginBinding.getActivity().stopService(serviceIntent);
unregisterReceiver();
mEngineHolder.destroy(mActivityPluginBinding);
TXLiveBase.setListener(null);
}
void onHandleAudioFocusPause() {
......
......@@ -19,9 +19,9 @@ import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterLivePlayerApi;
@SuppressWarnings("ConstantConditions")
public class FTXLivePlayerDispatcher implements FtxMessages.TXFlutterLivePlayerApi {
final IPlayersBridge bridge;
final ITXPlayersBridge bridge;
public FTXLivePlayerDispatcher(@NonNull IPlayersBridge dataBridge) {
public FTXLivePlayerDispatcher(@NonNull ITXPlayersBridge dataBridge) {
this.bridge = dataBridge;
}
......
......@@ -28,9 +28,9 @@ import com.tencent.vod.flutter.messages.FtxMessages.UInt8ListMsg;
@SuppressWarnings("ConstantConditions")
public class FTXVodPlayerDispatcher implements FtxMessages.TXFlutterVodPlayerApi {
final IPlayersBridge bridge;
final ITXPlayersBridge bridge;
public FTXVodPlayerDispatcher(@NonNull IPlayersBridge dataBridge) {
public FTXVodPlayerDispatcher(@NonNull ITXPlayersBridge dataBridge) {
this.bridge = dataBridge;
}
......
......@@ -5,7 +5,7 @@ package com.tencent.vod.flutter.messages;
import android.util.SparseArray;
import com.tencent.vod.flutter.FTXBasePlayer;
public interface IPlayersBridge {
public interface ITXPlayersBridge {
/**
* Get player list.
......
......@@ -3,14 +3,14 @@ package com.tencent.vod.flutter.model;
import android.os.Parcel;
import android.os.Parcelable;
public class PipResult implements Parcelable {
public class TXPipResult implements Parcelable {
private Float mPlayTime;
private boolean mIsPlaying;
private int mPlayerId;
public PipResult(){}
public TXPipResult(){}
protected PipResult(Parcel in) {
protected TXPipResult(Parcel in) {
if (in.readByte() == 0) {
mPlayTime = null;
} else {
......@@ -20,15 +20,15 @@ public class PipResult implements Parcelable {
mPlayerId = in.readInt();
}
public static final Creator<PipResult> CREATOR = new Creator<PipResult>() {
public static final Creator<TXPipResult> CREATOR = new Creator<TXPipResult>() {
@Override
public PipResult createFromParcel(Parcel in) {
return new PipResult(in);
public TXPipResult createFromParcel(Parcel in) {
return new TXPipResult(in);
}
@Override
public PipResult[] newArray(int size) {
return new PipResult[size];
public TXPipResult[] newArray(int size) {
return new TXPipResult[size];
}
};
......
......@@ -12,7 +12,7 @@ import com.tencent.vod.flutter.FTXEvent;
*
* 视频model
*/
public class VideoModel implements Parcelable {
public class TXVideoModel implements Parcelable {
private String videoUrl;
private int appId;
......@@ -22,9 +22,9 @@ public class VideoModel implements Parcelable {
private int mLiveType = TXLivePlayer.PLAY_TYPE_LIVE_FLV;
private String mToken;
public VideoModel() {}
public TXVideoModel() {}
protected VideoModel(Parcel in) {
protected TXVideoModel(Parcel in) {
videoUrl = in.readString();
appId = in.readInt();
fileId = in.readString();
......@@ -34,15 +34,15 @@ public class VideoModel implements Parcelable {
mToken = in.readString();
}
public static final Creator<VideoModel> CREATOR = new Creator<VideoModel>() {
public static final Creator<TXVideoModel> CREATOR = new Creator<TXVideoModel>() {
@Override
public VideoModel createFromParcel(Parcel in) {
return new VideoModel(in);
public TXVideoModel createFromParcel(Parcel in) {
return new TXVideoModel(in);
}
@Override
public VideoModel[] newArray(int size) {
return new VideoModel[size];
public TXVideoModel[] newArray(int size) {
return new TXVideoModel[size];
}
};
......
......@@ -18,9 +18,6 @@ import com.tencent.vod.flutter.messages.FtxMessages.PlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringMsg;
import com.tencent.vod.flutter.messages.FtxMessages.UInt8ListMsg;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -31,9 +28,9 @@ import java.util.Set;
* <p>
* 通用工具类
*/
public class CommonUtil {
public class TXCommonUtil {
private static final String TAG = "CommonUtil";
private static final String TAG = "TXCommonUtil";
private static final String KEY_MAX_BRIGHTNESS = "max_brightness";
private static final String KEY_IS_MIUI = "is_miui";
......@@ -73,7 +70,7 @@ public class CommonUtil {
} catch (Exception e) {
Log.getStackTraceString(e);
}
if (CommonUtil.isMIUI() && Build.VERSION.SDK_INT >= 33) {
if (TXCommonUtil.isMIUI() && Build.VERSION.SDK_INT >= 33) {
maxBrightness = 128F;
}
CACHE_MAP.put(KEY_MAX_BRIGHTNESS, maxBrightness);
......
......@@ -36,12 +36,13 @@ import com.tencent.rtmp.ITXVodPlayListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.TXPlayInfoParams;
import com.tencent.rtmp.TXVodPlayConfig;
import com.tencent.rtmp.TXVodPlayer;
import com.tencent.vod.flutter.FTXEvent;
import com.tencent.vod.flutter.FTXPIPManager.PipParams;
import com.tencent.vod.flutter.R;
import com.tencent.vod.flutter.model.PipResult;
import com.tencent.vod.flutter.model.VideoModel;
import com.tencent.vod.flutter.model.TXPipResult;
import com.tencent.vod.flutter.model.TXVideoModel;
import java.util.List;
import java.util.Set;
......@@ -75,7 +76,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
// In picture-in-picture mode, clicking the X in the upper right corner will trigger `onStop` first.
// Clicking the zoom button will not trigger `onStop`.
private boolean mIsNeedToStop = false;
private VideoModel mVideoModel;
private TXVideoModel mVideoModel;
private boolean mIsRegisterReceiver = false;
private PipParams mCurrentParams;
private Handler mMainHandler;
......@@ -138,6 +139,8 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
}
private void setVodPlayerListener() {
// set default config
mVodPlayer.setConfig(new TXVodPlayConfig());
mVodPlayer.setVodListener(this);
}
......@@ -245,7 +248,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
private void handlePipExitEvent() {
Bundle data = new Bundle();
PipResult pipResult = new PipResult();
TXPipResult pipResult = new TXPipResult();
if (mVideoModel.getPlayerType() == FTXEvent.PLAYER_VOD) {
Float currentPlayTime = mVodPlayer.getCurrentPlaybackTime();
pipResult.setPlayTime(currentPlayTime);
......@@ -354,7 +357,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
}
private void startPipVideoFromIntent(Intent intent) {
mVideoModel = (VideoModel) intent.getParcelableExtra(FTXEvent.EXTRA_NAME_VIDEO);
mVideoModel = (TXVideoModel) intent.getParcelableExtra(FTXEvent.EXTRA_NAME_VIDEO);
if (mIsSurfaceCreated) {
attachSurface(mVideoSurface.getHolder().getSurface());
startPlay();
......@@ -434,7 +437,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
private void bindAndroid12BugServiceIfNeed() {
if (Build.VERSION.SDK_INT >= VERSION_CODES.S) {
Intent serviceIntent = new Intent(this, Android12BridgeService.class);
Intent serviceIntent = new Intent(this, TXAndroid12BridgeService.class);
startService(serviceIntent);
bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
}
......
......@@ -15,7 +15,7 @@ import androidx.annotation.Nullable;
* 为了解决多次打开画中画的时候,启动画中画被认为是后台启动,导致无法启动的问题。
* 该问题出现于android 12版本上,目前只在MIUI的android 12版本上发现该问题。
*/
public class Android12BridgeService extends Service {
public class TXAndroid12BridgeService extends Service {
@Nullable
@Override
......@@ -24,8 +24,8 @@ public class Android12BridgeService extends Service {
}
class Android12BridgeServiceBinder extends Binder {
public Android12BridgeService getService() {
return Android12BridgeService.this;
public TXAndroid12BridgeService getService() {
return TXAndroid12BridgeService.this;
}
}
}
......@@ -7,9 +7,9 @@
#import <TXLiteAVSDK_Professional/TXVodPreloadManager.h>
#import <TXLiteAVSDK_Professional/TXVodDownloadManager.h>
#import "FTXEvent.h"
#import "CommonUtil.h"
#import "TXCommonUtil.h"
#import "FtxMessages.h"
#import "PredownloadFileHelperDelegate.h"
#import "TXPredownloadFileHelperDelegate.h"
@interface FTXDownloadManager ()<FlutterStreamHandler, TXVodPreloadManagerDelegate, TXVodDownloadDelegate, TXFlutterDownloadApi>
......@@ -71,13 +71,13 @@
[_eventSink success:[FTXDownloadManager getParamsWithEvent:EVENT_PREDOWNLOAD_ON_ERROR withParams:dict]];
}
- (void)removePreDelegate:(PredownloadFileHelperDelegate*)delegate {
- (void)removePreDelegate:(TXPredownloadFileHelperDelegate*)delegate {
@synchronized (self.delegateArray) {
[self.delegateArray removeObject:delegate];
}
}
- (void)addPreDelegate:(PredownloadFileHelperDelegate*)delegate {
- (void)addPreDelegate:(TXPredownloadFileHelperDelegate*)delegate {
@synchronized (self.delegateArray) {
if (![self.delegateArray containsObject:delegate]) {
[self.delegateArray addObject:delegate];
......@@ -168,7 +168,7 @@
if(nil != info) {
[dict setValue:info.playPath forKey:@"playPath"];
[dict setValue:@(info.progress) forKey:@"progress"];
[dict setValue:[CommonUtil getDownloadEventByState:(int)info.downloadState] forKey:@"downloadState"];
[dict setValue:[TXCommonUtil getDownloadEventByState:(int)info.downloadState] forKey:@"downloadState"];
[dict setValue:info.userName forKey:@"userName"];
[dict setValue:@(info.duration) forKey:@"duration"];
[dict setValue:@(info.playableDuration) forKey:@"playableDuration"];
......@@ -196,7 +196,7 @@
if(nil != info) {
msg.playPath = info.playPath;
msg.progress = @(info.progress);
msg.downloadState = [CommonUtil getDownloadEventByState:(int)info.downloadState];
msg.downloadState = [TXCommonUtil getDownloadEventByState:(int)info.downloadState];
msg.userName = info.userName;
msg.duration = @(info.duration);
msg.playableDuration = @(info.playableDuration);
......@@ -266,7 +266,7 @@
- (nullable BoolMsg *)deleteDownloadMediaInfoMsg:(nonnull TXVodDownloadMediaMsg *)msg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
TXVodDownloadMediaInfo *mediaInfo = [self parseMediaInfoFromInfo:msg.quality url:msg.url appId:msg.appId fileId:msg.fileId name:msg.userName];
BOOL deleteResult = [[TXVodDownloadManager shareInstance] deleteDownloadMediaInfo:mediaInfo];
return [CommonUtil boolMsgWith:deleteResult];
return [TXCommonUtil boolMsgWith:deleteResult];
}
- (nullable TXVodDownloadMediaMsg *)getDownloadInfoMsg:(nonnull TXVodDownloadMediaMsg *)msg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -326,7 +326,7 @@
preloadSize:preloadSizeMB
preferredResolution:preferredResolution
delegate:self];
return [CommonUtil intMsgWith:@(taskID)];
return [TXCommonUtil intMsgWith:@(taskID)];
}
- (void)stopDownloadMsg:(nonnull TXVodDownloadMediaMsg *)msg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -350,7 +350,7 @@
params.appId = (msg.appId != nil && [msg.appId isKindOfClass:[NSNumber class]]) ? [msg.appId intValue] : 0;
params.fileId = fileId;
params.sign = (msg.pSign != nil && [msg.pSign isKindOfClass:[NSString class]]) ? msg.pSign : @"";
__block PredownloadFileHelperDelegate *delegate = [[PredownloadFileHelperDelegate alloc] initWithBlock:tmpTaskId start:^(long tmpTaskId, int taskID, NSString * _Nonnull fileId, NSString * _Nonnull url, NSDictionary * _Nonnull param) {
__block TXPredownloadFileHelperDelegate *delegate = [[TXPredownloadFileHelperDelegate alloc] initWithBlock:tmpTaskId start:^(long tmpTaskId, int taskID, NSString * _Nonnull fileId, NSString * _Nonnull url, NSDictionary * _Nonnull param) {
[self onStartEvent:tmpTaskId taskID:taskID fileId:fileId url:url param:param];
} complete:^(int taskID, NSString * _Nonnull url) {
[self onComplete:taskID url:url];
......
......@@ -92,4 +92,25 @@
// 横屏,底部在左
#define ORIENTATION_LANDSCAPE_LEFT 414
// SDK event
// onLog
#define EVENT_ON_LOG 501
// onUpdateNetworkTime
#define EVENT_ON_UPDATE_NETWORK_TIME 502
// onLicenceLoaded
#define EVENT_ON_LICENCE_LOADED 503
// onCustomHttpDNS
#define EVENT_ON_CUSTOM_HTTP_DNS 504
// this events may be common,so remove the specific field identifier
#define EVENT_LOG_LEVEL "logLevel"
#define EVENT_LOG_MODULE "logModule"
#define EVENT_LOG_MSG "logMsg"
#define EVENT_ERR_CODE "errCode"
#define EVENT_ERR_MSG "errMsg"
#define EVENT_RESULT "result"
#define EVENT_REASON "reason"
#define EVENT_HOST_NAME "hostName"
#define EVENT_IPS "ips"
#endif // SUPERPLAYER_FLUTTER_IOS_CLASSES_FTXEVENT_H_
......@@ -8,7 +8,7 @@
#import <stdatomic.h>
#import <libkern/OSAtomic.h>
#import "FtxMessages.h"
#import "CommonUtil.h"
#import "TXCommonUtil.h"
static const int uninitialized = -1;
......@@ -359,7 +359,7 @@ static const int uninitialized = -1;
- (nullable BoolMsg *)enableHardwareDecodeEnable:(nonnull BoolPlayerMsg *)enable error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int r = [self enableHardwareDecode:enable.value];
return [CommonUtil boolMsgWith:r];
return [TXCommonUtil boolMsgWith:r];
}
- (nullable IntMsg *)enterPictureInPictureModePipParamsMsg:(nonnull PipParamsPlayerMsg *)pipParamsMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -373,11 +373,11 @@ static const int uninitialized = -1;
- (nullable IntMsg *)initializeOnlyAudio:(nonnull BoolPlayerMsg *)onlyAudio error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
NSNumber* textureId = [self createPlayer:onlyAudio.value.boolValue];
return [CommonUtil intMsgWith:textureId];
return [TXCommonUtil intMsgWith:textureId];
}
- (nullable BoolMsg *)isPlayingPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
return [CommonUtil boolMsgWith:[self isPlaying]];
return [TXCommonUtil boolMsgWith:[self isPlaying]];
}
- (void)pausePlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -418,16 +418,16 @@ static const int uninitialized = -1;
- (nullable BoolMsg *)startLivePlayPlayerMsg:(nonnull StringIntPlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int r = [self startLivePlay:playerMsg.strValue type:playerMsg.intValue.intValue];
return [CommonUtil boolMsgWith:r];
return [TXCommonUtil boolMsgWith:r];
}
- (nullable BoolMsg *)stopIsNeedClear:(nonnull BoolPlayerMsg *)isNeedClear error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
return [CommonUtil boolMsgWith:[self stopPlay]];
return [TXCommonUtil boolMsgWith:[self stopPlay]];
}
- (nullable IntMsg *)switchStreamUrl:(nonnull StringPlayerMsg *)url error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int r = [self switchStream:url.value];
return [CommonUtil intMsgWith:@(r)];
return [TXCommonUtil intMsgWith:@(r)];
}
@end
......@@ -10,7 +10,7 @@
#import <AVKit/AVKit.h>
#import "FTXEvent.h"
#import "FtxMessages.h"
#import "CommonUtil.h"
#import "TXCommonUtil.h"
static const int uninitialized = -1;
static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
......@@ -816,12 +816,12 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable BoolMsg *)enableHardwareDecodeEnable:(nonnull BoolPlayerMsg *)enable error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
bool res = [self enableHardwareDecode:enable.value];
return [CommonUtil boolMsgWith:res];
return [TXCommonUtil boolMsgWith:res];
}
- (nullable IntMsg *)enterPictureInPictureModePipParamsMsg:(nonnull PipParamsPlayerMsg *)pipParamsMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int res = [self enterPictureInPictureMode];
return [CommonUtil intMsgWith:@(res)];
return [TXCommonUtil intMsgWith:@(res)];
}
- (void)exitPictureInPictureModePlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -832,7 +832,7 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable IntMsg *)getBitrateIndexPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
long index = [self getBitrateIndex];
return [CommonUtil intMsgWith:@(index)];
return [TXCommonUtil intMsgWith:@(index)];
}
- (nullable DoubleMsg *)getBufferDurationPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -842,27 +842,27 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable DoubleMsg *)getCurrentPlaybackTimePlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
float time = [self getCurrentPlaybackTime];
return [CommonUtil doubleMsgWith:time];
return [TXCommonUtil doubleMsgWith:time];
}
- (nullable DoubleMsg *)getDurationPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
float time = [self getDuration];
return [CommonUtil doubleMsgWith:time];
return [TXCommonUtil doubleMsgWith:time];
}
- (nullable IntMsg *)getHeightPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int height = [self getHeight];
return [CommonUtil intMsgWith:@(height)];
return [TXCommonUtil intMsgWith:@(height)];
}
- (nullable UInt8ListMsg *)getImageSpriteTime:(nonnull DoublePlayerMsg *)time error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
NSData *data = [self getPlayerImageSprite:time.value];
return [CommonUtil uInt8MsgWith:data];
return [TXCommonUtil uInt8MsgWith:data];
}
- (nullable DoubleMsg *)getPlayableDurationPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
float time = [self getPlayableDuration];
return [CommonUtil doubleMsgWith:time];
return [TXCommonUtil doubleMsgWith:time];
}
- (nullable ListMsg *)getSupportedBitratePlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -874,7 +874,7 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable IntMsg *)getWidthPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int width = [self getWidth];
return [CommonUtil intMsgWith:@(width)];
return [TXCommonUtil intMsgWith:@(width)];
}
- (void)initImageSpriteSpriteInfo:(nonnull StringListPlayerMsg *)spriteInfo error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -883,15 +883,15 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable IntMsg *)initializeOnlyAudio:(nonnull BoolPlayerMsg *)onlyAudio error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
NSNumber* textureId = [self createPlayer:onlyAudio.value.boolValue];
return [CommonUtil intMsgWith:textureId];
return [TXCommonUtil intMsgWith:textureId];
}
- (nullable BoolMsg *)isLoopPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
return [CommonUtil boolMsgWith:[self isLoop]];
return [TXCommonUtil boolMsgWith:[self isLoop]];
}
- (nullable BoolMsg *)isPlayingPlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
return [CommonUtil boolMsgWith:[self isPlaying]];
return [TXCommonUtil boolMsgWith:[self isPlaying]];
}
- (void)pausePlayerMsg:(nonnull PlayerMsg *)playerMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -936,7 +936,7 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable BoolMsg *)setRequestAudioFocusFocus:(nonnull BoolPlayerMsg *)focus error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
// FlutterMethodNotImplemented
return [CommonUtil boolMsgWith:YES];
return [TXCommonUtil boolMsgWith:YES];
}
- (void)setStartTimeStartTime:(nonnull DoublePlayerMsg *)startTime error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -949,7 +949,7 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable BoolMsg *)startVodPlayUrl:(nonnull StringPlayerMsg *)url error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int r = [self startVodPlay:url.value];
return [CommonUtil boolMsgWith:r];
return [TXCommonUtil boolMsgWith:r];
}
- (void)startVodPlayWithParamsParams:(nonnull TXPlayInfoParamsPlayerMsg *)params error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -958,7 +958,7 @@ BOOL CGImageRefContainsAlpha(CGImageRef imageRef) {
- (nullable BoolMsg *)stopIsNeedClear:(nonnull BoolPlayerMsg *)isNeedClear error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
BOOL r = [self stopPlay];
return [CommonUtil boolMsgWith:r];
return [TXCommonUtil boolMsgWith:r];
}
@end
......@@ -3,7 +3,7 @@
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_SUPERPLAYERPLUGIN_H_
#import <Flutter/Flutter.h>
#import "CommonUtil.h"
#import "TXCommonUtil.h"
@interface SuperPlayerPlugin : NSObject<FlutterPlugin>
......
......@@ -13,7 +13,7 @@
#import "FTXVodPlayerDispatcher.h"
#import "FTXLivePlayerDispatcher.h"
@interface SuperPlayerPlugin ()<FlutterStreamHandler,FTXVodPlayerDelegate,TXFlutterSuperPlayerPluginAPI,TXFlutterNativeAPI, IPlayersBridge, FlutterPlugin>
@interface SuperPlayerPlugin ()<FlutterStreamHandler,FTXVodPlayerDelegate,TXFlutterSuperPlayerPluginAPI,TXFlutterNativeAPI, ITXPlayersBridge, FlutterPlugin, TXLiveBaseDelegate>
@property (nonatomic, strong) NSObject<FlutterPluginRegistrar>* registrar;
@property (nonatomic, strong) NSMutableDictionary *players;
......@@ -40,7 +40,7 @@ SuperPlayerPlugin* instance;
TXFlutterVodPlayerApiSetup([registrar messenger], [[FTXVodPlayerDispatcher alloc] initWithBridge:instance]);
TXFlutterLivePlayerApiSetup([registrar messenger], [[FTXLivePlayerDispatcher alloc] initWithBridge:instance]);
[registrar addApplicationDelegate:instance];
[TXLiveBase sharedInstance].delegate = instance;
}
- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
......@@ -238,7 +238,7 @@ SuperPlayerPlugin* instance;
FTXLivePlayer* player = [[FTXLivePlayer alloc] initWithRegistrar:self.registrar];
NSNumber *playerId = player.playerId;
_players[playerId] = player;
return [CommonUtil playerMsgWith:playerId];
return [TXCommonUtil playerMsgWith:playerId];
}
- (nullable PlayerMsg *)createVodPlayerWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -246,15 +246,15 @@ SuperPlayerPlugin* instance;
player.delegate = self;
NSNumber *playerId = player.playerId;
_players[playerId] = player;
return [CommonUtil playerMsgWith:playerId];
return [TXCommonUtil playerMsgWith:playerId];
}
- (nullable StringMsg *)getLiteAVSDKVersionWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
return [CommonUtil stringMsgWith:[TXLiveBase getSDKVersionStr]];
return [TXCommonUtil stringMsgWith:[TXLiveBase getSDKVersionStr]];
}
- (nullable StringMsg *)getPlatformVersionWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
return [CommonUtil stringMsgWith:[@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]];
return [TXCommonUtil stringMsgWith:[@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]];
}
- (void)releasePlayerPlayerId:(nonnull PlayerMsg *)playerId error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -279,16 +279,16 @@ SuperPlayerPlugin* instance;
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:preloadDataPath withIntermediateDirectories:NO attributes:nil error:&error];
[TXPlayerGlobalSetting setCacheFolderPath:preloadDataPath];
return [CommonUtil boolMsgWith:YES];
return [TXCommonUtil boolMsgWith:YES];
} else {
return [CommonUtil boolMsgWith:NO];
return [TXCommonUtil boolMsgWith:NO];
}
}
- (nullable IntMsg *)setGlobalEnvEnvConfig:(nonnull StringMsg *)envConfig error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
int setResult = [TXLiveBase setGlobalEnv:[envConfig.value UTF8String]];
return [CommonUtil intMsgWith:@(setResult)];
return [TXCommonUtil intMsgWith:@(setResult)];
}
- (void)setGlobalLicenseLicenseMsg:(nonnull LicenseMsg *)licenseMsg error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -307,7 +307,7 @@ SuperPlayerPlugin* instance;
- (nullable BoolMsg *)startVideoOrientationServiceWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
// only for android
return [CommonUtil boolMsgWith:YES];
return [TXCommonUtil boolMsgWith:YES];
}
#pragma mark nativeAPI
......@@ -318,23 +318,23 @@ SuperPlayerPlugin* instance;
- (nullable DoubleMsg *)getBrightnessWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
NSNumber *brightness = [NSNumber numberWithFloat:[UIScreen mainScreen].brightness];
return [CommonUtil doubleMsgWith:brightness.doubleValue];
return [TXCommonUtil doubleMsgWith:brightness.doubleValue];
}
- (DoubleMsg *)getSysBrightnessWithError:(FlutterError * _Nullable __autoreleasing *)error {
NSNumber *brightness = [NSNumber numberWithFloat:[UIScreen mainScreen].brightness];
return [CommonUtil doubleMsgWith:brightness.doubleValue];
return [TXCommonUtil doubleMsgWith:brightness.doubleValue];
}
- (nullable DoubleMsg *)getSystemVolumeWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
NSNumber *volume = [NSNumber numberWithFloat:[audioManager getVolume]];
return [CommonUtil doubleMsgWith:volume.doubleValue];
return [TXCommonUtil doubleMsgWith:volume.doubleValue];
}
- (nullable IntMsg *)isDeviceSupportPipWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
BOOL isSupport = [TXVodPlayer isSupportPictureInPicture];
int pipSupportResult = isSupport ? 0 : ERROR_IOS_PIP_DEVICE_NOT_SUPPORT;
return [CommonUtil intMsgWith:@(pipSupportResult)];
return [TXCommonUtil intMsgWith:@(pipSupportResult)];
}
- (void)requestAudioFocusWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......@@ -370,4 +370,39 @@ SuperPlayerPlugin* instance;
return self.players;
}
#pragma mark TXLiveBaseDelegate
- (void)onLog:(NSString *)log LogLevel:(int)level WhichModule:(NSString *)module {
// [_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_ON_LOG withParams:@{
// @(EVENT_LOG_LEVEL) : @(level),
// @(EVENT_LOG_MODULE) : module,
// @(EVENT_LOG_MSG) : log
// }]];
// this may be too busy, so currently do not throw on the Flutter side
}
- (void)onUpdateNetworkTime:(int)errCode message:(NSString *)errMsg {
// [_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_ON_UPDATE_NETWORK_TIME withParams:@{
// @(EVENT_ERR_CODE) : @(errCode),
// @(EVENT_ERR_MSG) : errMsg,
// }]];
// This will be opened in a subsequent version
}
- (void)onLicenceLoaded:(int)result Reason:(NSString *)reason {
[_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_ON_LICENCE_LOADED withParams:@{
@(EVENT_RESULT) : @(result),
@(EVENT_REASON) : reason,
}]];
}
- (void)onCustomHttpDNS:(NSString *)hostName ipList:(NSMutableArray<NSString *> *)list {
// [_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_ON_LICENCE_LOADED withParams:@{
// @(EVENT_HOST_NAME) : hostName,
// @(EVENT_IPS) : list,
// }]];
// This will be opened in a subsequent version
}
@end
......@@ -5,7 +5,7 @@
#import "FTXEvent.h"
#import "FtxMessages.h"
@interface CommonUtil : NSObject
@interface TXCommonUtil : NSObject
+(NSNumber*)getDownloadEventByState:(int)downloadState;
......
// Copyright (c) 2022 Tencent. All rights reserved.
#import "CommonUtil.h"
#import "TXCommonUtil.h"
#import <Flutter/Flutter.h>
@implementation CommonUtil
@implementation TXCommonUtil
+ (NSNumber*)getDownloadEventByState:(int)downloadState{
int result;
......
// Copyright (c) 2022 Tencent. All rights reserved.
#ifndef SUPERPLAYER_FLUTTER_IOS_CLASSES_HELPER_PREDOWNLOADFILEHELPERDELEGATE_H_
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_HELPER_PREDOWNLOADFILEHELPERDELEGATE_H_
#ifndef SUPERPLAYER_FLUTTER_IOS_CLASSES_HELPER_TXPREDOWNLOADFILEHELPERDELEGATE_H_
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_HELPER_TXPREDOWNLOADFILEHELPERDELEGATE_H_
#import <Foundation/Foundation.h>
#import <TXLiteAVSDK_Professional/TXVodPreloadManager.h>
......@@ -11,7 +11,7 @@ typedef void (^FTXPreDownloadOnStart)(long tmpTaskId, int taskID, NSString* file
typedef void (^FTXPreDownloadOnCompelete)(int taskID, NSString* url);
typedef void (^FTXPreDownloadOnError)(long tmpTaskId, int taskID, NSString* url, NSError* error);
@interface PredownloadFileHelperDelegate : NSObject<TXVodPreloadManagerDelegate>
@interface TXPredownloadFileHelperDelegate : NSObject<TXVodPreloadManagerDelegate>
- (instancetype)initWithBlock:(long)tmpTaskId start:(FTXPreDownloadOnStart)onStart
complete:(FTXPreDownloadOnCompelete)onComplete
......@@ -20,4 +20,4 @@ typedef void (^FTXPreDownloadOnError)(long tmpTaskId, int taskID, NSString* url,
@end
NS_ASSUME_NONNULL_END
#endif // SUPERPLAYER_FLUTTER_IOS_CLASSES_HELPER_PREDOWNLOADFILEHELPERDELEGATE_H_
#endif // SUPERPLAYER_FLUTTER_IOS_CLASSES_HELPER_TXPREDOWNLOADFILEHELPERDELEGATE_H_
// Copyright (c) 2022 Tencent. All rights reserved.
#import "PredownloadFileHelperDelegate.h"
#import "TXPredownloadFileHelperDelegate.h"
@interface PredownloadFileHelperDelegate()
@interface TXPredownloadFileHelperDelegate()
@property (nonatomic, assign)long tmpTaskId;
@property (nonatomic, strong)FTXPreDownloadOnStart onStartBlock;
......@@ -10,7 +10,7 @@
@end
@implementation PredownloadFileHelperDelegate
@implementation TXPredownloadFileHelperDelegate
- (instancetype)initWithBlock:(long)tmpTaskId start:(FTXPreDownloadOnStart)onStart complete:(FTXPreDownloadOnCompelete)onComplete error:(FTXPreDownloadOnError)onError {
self = [super init];
......
......@@ -4,13 +4,13 @@
#import <Foundation/Foundation.h>
#import "FtxMessages.h"
#import "IPlayersBridge.h"
#import "ITXPlayersBridge.h"
@interface FTXLivePlayerDispatcher : NSObject<TXFlutterLivePlayerApi>
@property(atomic, strong) id<IPlayersBridge> bridge;
@property(atomic, strong) id<ITXPlayersBridge> bridge;
- (instancetype)initWithBridge:(id<IPlayersBridge>)dataBridge;
- (instancetype)initWithBridge:(id<ITXPlayersBridge>)dataBridge;
@end
......
......@@ -4,7 +4,7 @@
@implementation FTXLivePlayerDispatcher
- (instancetype)initWithBridge:(id<IPlayersBridge>)dataBridge {
- (instancetype)initWithBridge:(id<ITXPlayersBridge>)dataBridge {
if(self = [self init]) {
self.bridge = dataBridge;
}
......
......@@ -4,13 +4,13 @@
#import <Foundation/Foundation.h>
#import "FtxMessages.h"
#import "IPlayersBridge.h"
#import "ITXPlayersBridge.h"
@interface FTXVodPlayerDispatcher : NSObject<TXFlutterVodPlayerApi>
@property(atomic, strong) id<IPlayersBridge> bridge;
@property(atomic, strong) id<ITXPlayersBridge> bridge;
- (instancetype)initWithBridge:(id<IPlayersBridge>)dataBridge;
- (instancetype)initWithBridge:(id<ITXPlayersBridge>)dataBridge;
@end
......
......@@ -5,7 +5,7 @@
@implementation FTXVodPlayerDispatcher
- (instancetype)initWithBridge:(id<IPlayersBridge>)dataBridge {
- (instancetype)initWithBridge:(id<ITXPlayersBridge>)dataBridge {
if(self = [self init]) {
self.bridge = dataBridge;
}
......
// Copyright (c) 2022 Tencent. All rights reserved.
#ifndef SUPERPLAYER_FLUTTER_IOS_CLASSES_MESSAGES_IPLAYERSBRIDGE_H_
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_MESSAGES_IPLAYERSBRIDGE_H_
#ifndef SUPERPLAYER_FLUTTER_IOS_CLASSES_MESSAGES_ITXPLAYERSBRIDGE_H_
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_MESSAGES_ITXPLAYERSBRIDGE_H_
#import <Foundation/Foundation.h>
@protocol IPlayersBridge
@protocol ITXPlayersBridge
-(NSMutableDictionary*)getPlayers;
@end
#endif // SUPERPLAYER_FLUTTER_IOS_CLASSES_MESSAGES_IPLAYERSBRIDGE_H_
#endif // SUPERPLAYER_FLUTTER_IOS_CLASSES_MESSAGES_ITXPLAYERSBRIDGE_H_
......@@ -24,7 +24,7 @@ class SuperPlayerPlugin {
final StreamController<Map<dynamic, dynamic>> _eventPipStreamController = StreamController.broadcast();
/// Native interaction, common event listener, events from the plugin, such as sound change events.
/// 原生交互,通用事件监听,来自插件的事件,例如 声音变化等事件
/// 原生交互,通用事件监听,来自插件的事件,例如 声音变化、播放器SDK加载鉴权等事件
Stream<Map<dynamic, dynamic>> get onEventBroadcast => _eventStreamController.stream;
/// Native interaction, common event listener, events from the native container,
......@@ -32,12 +32,20 @@ class SuperPlayerPlugin {
/// 原生交互,通用事件监听,来自原生容器的事件,例如 PIP事件、activity/controller 生命周期变化
Stream<Map<dynamic, dynamic>> get onExtraEventBroadcast => _eventPipStreamController.stream;
FTXLicenceLoadedListener? _licenseLoadedListener;
SuperPlayerPlugin._internal() {
EventChannel eventChannel = EventChannel("cloud.tencent.com/playerPlugin/event");
eventChannel.receiveBroadcastStream("event").listen(_eventHandler, onError: _errorHandler);
EventChannel pipEventChanne = EventChannel("cloud.tencent.com/playerPlugin/componentEvent");
pipEventChanne.receiveBroadcastStream("pipEvent").listen(_pipEventHandler, onError: _errorHandler);
onEventBroadcast.listen((event) {
int evtCode = event["event"];
if (evtCode == TXVodPlayEvent.EVENT_ON_LICENCE_LOADED) {
_licenseLoadedListener?.call(event[TXVodPlayEvent.EVENT_RESULT], event[TXVodPlayEvent.EVENT_REASON]);
}
});
}
_pipEventHandler(event) {
......@@ -179,7 +187,7 @@ class SuperPlayerPlugin {
/// Get the current system volume, range: 0.0 ~ 1.0
/// 获得当前系统音量,范围:0.0 ~ 1.0
static Future<double?> getSystemVolume() async {
DoubleMsg doubleMsg = await _nativeAPI.getSystemVolume();
DoubleMsg doubleMsg = await _nativeAPI.getSystemVolume();
return doubleMsg.value;
}
......@@ -268,7 +276,17 @@ class SuperPlayerPlugin {
/// @param isRegister:true register system brightness
/// :false unregister system brightness
///
static Future<void>registerSysBrightness(bool isRegister) async {
static Future<void> registerSysBrightness(bool isRegister) async {
await _nativeAPI.registerSysBrightness(BoolMsg()..value = isRegister);
}
///
/// 设置SDK的监听,目前有licence加载监听,后续还会陆续开放其他类型的监听
///
/// Set up SDK listeners, currently there is a license loading listener, and other types of listeners
/// will be gradually opened in the future.
///
void setSDKListener({FTXLicenceLoadedListener? licenceLoadedListener}) {
_licenseLoadedListener = licenceLoadedListener;
}
}
......@@ -333,6 +333,13 @@ abstract class TXVodPlayEvent {
// Error occurred during video download.
// 视频下载错误
static const EVENT_DOWNLOAD_ERROR = 305;
// SDK event
// onLicenceLoaded
static const EVENT_ON_LICENCE_LOADED = 503;
static const EVENT_RESULT = "result";
static const EVENT_REASON = "reason";
}
abstract class TXVodNetEvent {
......@@ -685,3 +692,5 @@ typedef FTXPredownlodOnErrorListener = void Function(int taskId, String url, int
// 视频下载时间回调Listener
typedef FTXDownlodOnStateChangeListener = void Function(int event, TXVodDownloadMediaInfo info);
typedef FTXDownlodOnErrorListener = void Function(int errorCode, String errorMsg, TXVodDownloadMediaInfo info);
typedef FTXLicenceLoadedListener = void Function(int result, String reason);
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论