Search in sources :

Example 1 with UrlInterrupter

use of com.herewhite.sdk.domain.UrlInterrupter in project whiteboard-android by netless-io.

the class PlayActivity method initPlayer.

// endregion
protected void initPlayer(String uuid, String roomToken) {
    WhiteSdk whiteSdk = new WhiteSdk(mWhiteboardView, PlayActivity.this, new WhiteSdkConfiguration(demoAPI.getAppId(), true), new UrlInterrupter() {

        @Override
        public String urlInterrupter(String sourceUrl) {
            return sourceUrl;
        }
    });
    PlayerConfiguration playerConfiguration = new PlayerConfiguration(uuid, roomToken);
    // 只回放 60 秒。如果时间太长,seek bar 进度条移动不明显。
    // 实际播放时,需要对齐原始音视频和白板
    playerConfiguration.setDuration(60000L);
    whiteSdk.createPlayer(playerConfiguration, this, new Promise<Player>() {

        @Override
        public void then(Player wPlayer) {
            mPlaybackPlayer = wPlayer;
            mPlayerSyncManager.setWhitePlayer(mPlaybackPlayer);
            setupSeekBar();
            if (mWhiteMediaPlayer != null) {
                if (mIsUsedExoPlayer) {
                    ((WhiteExoPlayer) mWhiteMediaPlayer).setPlayerSyncManager(mPlayerSyncManager);
                } else {
                    ((WhiteIjkPlayer) mWhiteMediaPlayer).setPlayerSyncManager(mPlayerSyncManager);
                }
            }
            // seek 一次才能主动触发
            mPlaybackPlayer.seekToScheduleTime(0);
            enableBtn();
            play();
            mSeekBarUpdateHandler.postDelayed(mUpdateSeekBar, 100);
            testMarkIdling(true);
        }

        @Override
        public void catchEx(SDKError t) {
            alert("create player error, ", t.getJsStack());
        }
    });
}
Also used : UrlInterrupter(com.herewhite.sdk.domain.UrlInterrupter) WhiteExoPlayer(com.herewhite.demo.player.exo.WhiteExoPlayer) NativePlayer(com.herewhite.sdk.combinePlayer.NativePlayer) Player(com.herewhite.sdk.Player) WhiteIjkPlayer(com.herewhite.demo.player.ijk.WhiteIjkPlayer) PlayerConfiguration(com.herewhite.sdk.domain.PlayerConfiguration) WhiteSdkConfiguration(com.herewhite.sdk.WhiteSdkConfiguration) SDKError(com.herewhite.sdk.domain.SDKError) WhiteSdk(com.herewhite.sdk.WhiteSdk)

Example 2 with UrlInterrupter

use of com.herewhite.sdk.domain.UrlInterrupter in project whiteboard-android by netless-io.

the class PureReplayActivity method initPlayer.

// endregion
protected void initPlayer(String uuid, String roomToken) {
    WhiteSdk whiteSdk = new WhiteSdk(whiteboardView, PureReplayActivity.this, new WhiteSdkConfiguration(demoAPI.getAppId(), true), new UrlInterrupter() {

        @Override
        public String urlInterrupter(String sourceUrl) {
            return sourceUrl;
        }
    });
    PlayerConfiguration playerConfiguration = new PlayerConfiguration(uuid, roomToken);
    // 只回放 60 秒。如果时间太长,seek bar 进度条移动不明显。
    playerConfiguration.setDuration(60000l);
    // 如果只想实现部分 PlayerEventListener 可以使用 AbstractPlayerEventListener,替换其中想实现的方法
    whiteSdk.createPlayer(playerConfiguration, this, new Promise<Player>() {

        @Override
        public void then(Player wPlayer) {
            player = wPlayer;
            setupSeekBar();
            wPlayer.seekToScheduleTime(0);
            wPlayer.play();
            mSeekBarUpdateHandler.postDelayed(mUpdateSeekBar, 100);
            enableBtn();
        }

        @Override
        public void catchEx(SDKError t) {
            Log.e(TAG, "create player error" + t.getStackTrace().toString());
            alert("创建回放失败", t.getJsStack());
        }
    });
}
Also used : UrlInterrupter(com.herewhite.sdk.domain.UrlInterrupter) Player(com.herewhite.sdk.Player) PlayerConfiguration(com.herewhite.sdk.domain.PlayerConfiguration) WhiteSdkConfiguration(com.herewhite.sdk.WhiteSdkConfiguration) SDKError(com.herewhite.sdk.domain.SDKError) WhiteSdk(com.herewhite.sdk.WhiteSdk)

Aggregations

Player (com.herewhite.sdk.Player)2 WhiteSdk (com.herewhite.sdk.WhiteSdk)2 WhiteSdkConfiguration (com.herewhite.sdk.WhiteSdkConfiguration)2 PlayerConfiguration (com.herewhite.sdk.domain.PlayerConfiguration)2 SDKError (com.herewhite.sdk.domain.SDKError)2 UrlInterrupter (com.herewhite.sdk.domain.UrlInterrupter)2 WhiteExoPlayer (com.herewhite.demo.player.exo.WhiteExoPlayer)1 WhiteIjkPlayer (com.herewhite.demo.player.ijk.WhiteIjkPlayer)1 NativePlayer (com.herewhite.sdk.combinePlayer.NativePlayer)1