Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问一下,第二次再推流的时候就没反应了 #13

Open
guodetm opened this issue Aug 22, 2017 · 1 comment
Open

问一下,第二次再推流的时候就没反应了 #13

guodetm opened this issue Aug 22, 2017 · 1 comment

Comments

@guodetm
Copy link

guodetm commented Aug 22, 2017

我用的是推流端的示例代码,再第二次点击开始按钮的时候接收端就接收不到推流了,能麻烦看下是什么问题吗,谢谢。
就是调用了stop()方法之后再调用start()方法就推流不上去了,程序没有报错。

@chenyayun
Copy link

因为停止推流之后,推流线程被停止了。所以这样
原始代码
`
/**
* 停止发布
*/
public void stopPublish() {
Runnable runnable = new Runnable() {
@OverRide
public void run() {
mRtmpPublisher.stop();
isPublish = false;

            loop = false;
            if (workThread != null) {
                workThread.interrupt();
            }
        }
    };

    mRunnables.add(runnable);
}

`

我的修改方式是:MediaPublisher.init()这个方法由startPublish()调用。
`
/**
* 发布
*/
public void starPublish() {
if (isPublish) {
return;
}

    init();

    if (videoParams == null || audioParams == null) {
        Log.w(TAG, "video param or audio param is null");
        return;
    }

    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            //初始化
            int ret = mRtmpPublisher.init(mConfig.publishUrl,
                    videoParams.previewWidth,
                    videoParams.previewHeight, mConfig.timeOut);
            if (ret < 0) {
                Log.e(TAG, "连接失败");
                return;
            }

            isPublish = true;
        }
    };
    mRunnables.add(runnable);
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants