全部产品
视频直播

主播结束直播

更新时间:2017-09-04 19:09:27   分享:   

  1. 主播向APP Server发送结束直播的通知,并结束推流。

    (客户端代码:LifecyclePublisherMgr.java文件中,调用接口stopPublishing、finishPublishing)

    1. mInviteServiceBI.leaveCall(playerUID, mRoomID, new ServiceBI.Callback()
    2. public void stopPublish() {
    3. if (null != mChatHost && (mStatus & STATUS_PREVIEW) == STATUS_PREVIEW) {
    4. Log.d(TAG, "Call mChatHost.stopPublishing()");
    5. mChatHost.stopPublishing();
    6. Log.d(TAG, "Call mChatHost.finishPublishing()");
    7. mChatHost.finishPublishing();
    8. mStatus = STATUS_MASK;
    9. }
    10. }
  2. APP Server向观众A、B、C告知直播结束。

    (APP Server端代码:service\live.js文件中)

    1. msg = util.createMqttMsg({
    2. roomId: roomId,
    3. uid: liveInfo.uid,
    4. name: liveInfo.name,
    5. }, 15);
    6. mns.publish(roomId, msg, 5);
  3. 观众A、B、C退出直播(即结束播放混流地址)。

    (客户端代码:PublisherSDKHelper.java文件中,调用接口offlineChat、stopPlaying)

    1. public void abortChat() {
    2. if (mChatParter != null && isChatting) {
    3. Log.d(TAG, "Call mChatParter.offlineChat()");
    4. mCallback.onEvent(IPlayerMgr.TYPE_PARTER_OPT_START, null);
    5. mChatParter.offlineChat();
    6. isChatting = false;
    7. hasOnlineChats = false;
    8. }
    9. }
    10. public void stopPlaying() {
    11. if (mChatParter != null && isPlaying) {
    12. Log.d(TAG, "Call mChatParter.stopPlaying()");
    13. mCallback.onEvent(IPlayerMgr.TYPE_PARTER_OPT_START, null);
    14. mChatParter.stopPlaying();
    15. isPlaying = false;
    16. }
    17. }
本文导读目录
本文导读目录
以上内容是否对您有帮助?