当前位置: 首页>>代码示例>>Java>>正文


Java RtcEngine类代码示例

本文整理汇总了Java中io.agora.rtc.RtcEngine的典型用法代码示例。如果您正苦于以下问题:Java RtcEngine类的具体用法?Java RtcEngine怎么用?Java RtcEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RtcEngine类属于io.agora.rtc包,在下文中一共展示了RtcEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onVoiceMuteClicked

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
public void onVoiceMuteClicked(View view) {
    log.info("onVoiceMuteClicked " + view + " " + mUidsList.size() + " video_status: " + mVideoMuted + " audio_status: " + mAudioMuted);
    if (mUidsList.size() == 0) {
        return;
    }

    RtcEngine rtcEngine = rtcEngine();
    rtcEngine.muteLocalAudioStream(mAudioMuted = !mAudioMuted);

    ImageView iv = (ImageView) view;

    if (mAudioMuted) {
        iv.setColorFilter(getResources().getColor(R.color.agora_blue), PorterDuff.Mode.MULTIPLY);
    } else {
        iv.clearColorFilter();
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:18,代码来源:ChatActivity.java

示例2: initUIandEvent

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
@Override
protected void initUIandEvent() {
    event().addEventHandler(this);

    Intent i = getIntent();
    int cRole = i.getIntExtra(ConstantApp.ACTION_KEY_CROLE, 0);

    if (cRole == 0) {
        throw new RuntimeException("Should not reach here");
    }

    String roomName = i.getStringExtra(ConstantApp.ACTION_KEY_ROOM_NAME);

    doConfigEngine(cRole);

    mGridVideoViewContainer = (GridVideoViewContainer) findViewById(R.id.grid_video_view_container);
    mGridVideoViewContainer.setItemEventHandler(new VideoViewEventListener() {
        @Override
        public void onItemDoubleClick(View v, Object item) {
            log.debug("onItemDoubleClick " + v + " " + item);

            if (mUidsList.size() < 2) {
                return;
            }

            if (mViewType == VIEW_TYPE_DEFAULT)
                switchToSmallVideoView(((VideoStatusData) item).mUid);
            else
                switchToDefaultVideoView();
        }
    });

    ImageView button1 = (ImageView) findViewById(R.id.btn_1);
    ImageView button2 = (ImageView) findViewById(R.id.btn_2);
    ImageView button3 = (ImageView) findViewById(R.id.btn_3);

    if (isBroadcaster(cRole)) {
        SurfaceView surfaceV = RtcEngine.CreateRendererView(getApplicationContext());
        rtcEngine().setupLocalVideo(new VideoCanvas(surfaceV, VideoCanvas.RENDER_MODE_HIDDEN, 0));
        surfaceV.setZOrderOnTop(true);
        surfaceV.setZOrderMediaOverlay(true);

        mUidsList.put(0, surfaceV); // get first surface view

        mGridVideoViewContainer.initViewContainer(getApplicationContext(), 0, mUidsList); // first is now full view
        worker().preview(true, surfaceV, 0);
        broadcasterUI(button1, button2, button3);
    } else {
        audienceUI(button1, button2, button3);
    }

    worker().joinChannel(roomName, config().mUid);

    TextView textRoomName = (TextView) findViewById(R.id.room_name);
    textRoomName.setText(roomName);
}
 
开发者ID:AgoraIO,项目名称:OpenLive-Android,代码行数:57,代码来源:LiveRoomActivity.java

示例3: ensureRtcEngineReadyLock

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private RtcEngine ensureRtcEngineReadyLock() {
    if (mRtcEngine == null) {
        String appId = mContext.getString(R.string.private_app_id);
        if (TextUtils.isEmpty(appId)) {
            throw new RuntimeException("NEED TO use your App ID, get your own ID at https://dashboard.agora.io/");
        }
        try {
            mRtcEngine = RtcEngine.create(mContext, appId, mEngineEventHandler.mRtcEventHandler);
        } catch (Exception e) {
            log.error(Log.getStackTraceString(e));
            throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
        }
        mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION);
        mRtcEngine.enableAudioVolumeIndication(200, 3); // 200 ms
        mRtcEngine.setLogFile(Environment.getExternalStorageDirectory()
                + File.separator + mContext.getPackageName() + "/log/agora-rtc.log");
    }
    return mRtcEngine;
}
 
开发者ID:AgoraIO,项目名称:OpenVoiceCall-Android,代码行数:20,代码来源:WorkerThread.java

示例4: onVoiceMuteClicked

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
public void onVoiceMuteClicked(View view) {
    log.info("onVoiceMuteClicked " + view + " audio_status: " + mAudioMuted);

    RtcEngine rtcEngine = rtcEngine();
    rtcEngine.muteLocalAudioStream(mAudioMuted = !mAudioMuted);

    ImageView iv = (ImageView) view;

    if (mAudioMuted) {
        iv.setColorFilter(getResources().getColor(R.color.agora_blue), PorterDuff.Mode.MULTIPLY);
    } else {
        iv.clearColorFilter();
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVoiceCall-Android,代码行数:15,代码来源:ChatActivity.java

示例5: ensureRtcEngineReadyLock

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private RtcEngine ensureRtcEngineReadyLock() {
    if (mRtcEngine == null) {
        String appId = mContext.getString(R.string.private_app_id);
        if (TextUtils.isEmpty(appId)) {
            throw new RuntimeException("NEED TO use your App ID, get your own ID at https://dashboard.agora.io/");
        }
        try {
            mRtcEngine = RtcEngine.create(mContext, appId, mEngineEventHandler.mRtcEventHandler);
        } catch (Exception e) {
            log.error(Log.getStackTraceString(e));
            throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
        }
        mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION);
        mRtcEngine.enableVideo();
        mRtcEngine.enableAudioVolumeIndication(200, 3); // 200 ms
        mRtcEngine.setLogFile(Environment.getExternalStorageDirectory()
                + File.separator + mContext.getPackageName() + "/log/agora-rtc.log");
    }
    return mRtcEngine;
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:21,代码来源:WorkerThread.java

示例6: sendChannelMsg

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private void sendChannelMsg(String msgStr) {
    RtcEngine rtcEngine = rtcEngine();
    if (mDataStreamId <= 0) {
        mDataStreamId = rtcEngine.createDataStream(true, true); // boolean reliable, boolean ordered
    }

    if (mDataStreamId < 0) {
        String errorMsg = "Create data stream error happened " + mDataStreamId;
        log.warn(errorMsg);
        showLongToast(errorMsg);
        return;
    }

    byte[] encodedMsg;
    try {
        encodedMsg = msgStr.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        encodedMsg = msgStr.getBytes();
    }

    rtcEngine.sendStreamMessage(mDataStreamId, encodedMsg);
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:23,代码来源:ChatActivity.java

示例7: headsetPlugged

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
/**
 * 是否使用蓝牙耳机
 *
 * @param plugged
 */
private void headsetPlugged(final boolean plugged) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (isFinishing()) {
                return;
            }

            RtcEngine rtcEngine = rtcEngine();
            rtcEngine.setEnableSpeakerphone(!plugged);
        }
    }).start();
}
 
开发者ID:wzc25151,项目名称:lrs_android,代码行数:24,代码来源:AgoraActivity.java

示例8: ensureRtcEngineReadyLock

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private RtcEngine ensureRtcEngineReadyLock() {
    if (mRtcEngine == null) {
        String appId = mContext.getString(R.string.private_app_id);
        if (TextUtils.isEmpty(appId)) {
            throw new RuntimeException("NEED TO use your App ID, get your own ID at https://dashboard.agora.io/");
        }
        try {
            mRtcEngine = RtcEngine.create(mContext, appId, mEngineEventHandler.mRtcEventHandler);
        } catch (Exception e) {
            log.error(Log.getStackTraceString(e));
            throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
        }
        mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
        mRtcEngine.enableVideo();
        mRtcEngine.setLogFile(Environment.getExternalStorageDirectory()
                + File.separator + mContext.getPackageName() + "/log/agora-rtc.log");
        mRtcEngine.enableDualStreamMode(true);
    }
    return mRtcEngine;
}
 
开发者ID:AgoraIO,项目名称:OpenLive-Android,代码行数:21,代码来源:WorkerThread.java

示例9: ensureRtcEngineReadyLock

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private RtcEngine ensureRtcEngineReadyLock() {
    if (mRtcEngine == null) {
        String appId = mContext.getString(R.string.private_app_id);
        if (TextUtils.isEmpty(appId)) {
            throw new RuntimeException("NEED TO use your App ID, get your own ID at https://dashboard.agora.io/");
        }
        mRtcEngine = RtcEngine.create(mContext, appId, mEngineEventHandler.mRtcEventHandler);
        if (isLive) {
            mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
        } else {
            mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION);
        }
        mRtcEngine.enableVideo();
        mRtcEngine.enableAudioVolumeIndication(200, 3); // 200 ms
        mRtcEngine.setLogFile(Environment.getExternalStorageDirectory()
                + File.separator + mContext.getPackageName() + "/log/agora-rtc.log");
    }
    return mRtcEngine;
}
 
开发者ID:huangjingqiang,项目名称:SWDemo,代码行数:20,代码来源:WorkerThread.java

示例10: onError

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
@Override
public void onError(int error) {
    log.debug("onError " + error);

    Iterator<AGEventHandler> it = mEventHandlerList.keySet().iterator();
    while (it.hasNext()) {
        AGEventHandler handler = it.next();
        handler.onExtraCallback(AGEventHandler.EVENT_TYPE_ON_AGORA_MEDIA_ERROR, error, RtcEngine.getErrorDescription(error));
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVoiceCall-Android,代码行数:11,代码来源:MyEngineEventHandler.java

示例11: onDestroy

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
@Override
protected void onDestroy() {
    super.onDestroy();

    leaveChannel();
    RtcEngine.destroy();

    if (mCustomizedCameraRenderer != null) {
        mCustomizedCameraRenderer.onDestroy();
        mCustomizedCameraRenderer = null;
    }

    mRtcEngine = null;
}
 
开发者ID:AgoraIO,项目名称:Agora-Video-Source-Android,代码行数:15,代码来源:VideoChatViewActivity.java

示例12: initializeAgoraEngine

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private void initializeAgoraEngine() {
    try {
        mRtcEngine = RtcEngine.create(getBaseContext(), getString(R.string.agora_app_id), mRtcEventHandler);
    } catch (Exception e) {
        Log.e(LOG_TAG, Log.getStackTraceString(e));

        throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
    }
    mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
}
 
开发者ID:AgoraIO,项目名称:Agora-Video-Source-Android,代码行数:11,代码来源:VideoChatViewActivity.java

示例13: setupRemoteVideo

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
private void setupRemoteVideo(int uid) {
    FrameLayout container = (FrameLayout) findViewById(R.id.remote_video_view_container);

    if (container.getChildCount() >= 1) {
        return;
    }

    SurfaceView surfaceView = RtcEngine.CreateRendererView(getBaseContext());
    container.addView(surfaceView);
    mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_ADAPTIVE, uid));
    surfaceView.setTag(uid); // for mark purpose
    View tipMsg = findViewById(R.id.quick_tips_when_use_agora_sdk); // optional UI
    tipMsg.setVisibility(View.GONE);
}
 
开发者ID:AgoraIO,项目名称:Agora-Video-Source-Android,代码行数:15,代码来源:VideoChatViewActivity.java

示例14: onError

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
@Override
public void onError(int error) {
    log.debug("onError " + error + " " + RtcEngine.getErrorDescription(error));

    Iterator<AGEventHandler> it = mEventHandlerList.keySet().iterator();
    while (it.hasNext()) {
        AGEventHandler handler = it.next();
        handler.onExtraCallback(AGEventHandler.EVENT_TYPE_ON_AGORA_MEDIA_ERROR, error, RtcEngine.getErrorDescription(error));
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:11,代码来源:MyEngineEventHandler.java

示例15: onVoiceChatClicked

import io.agora.rtc.RtcEngine; //导入依赖的package包/类
public void onVoiceChatClicked(View view) {
    log.info("onVoiceChatClicked " + view + " " + mUidsList.size() + " video_status: " + mVideoMuted + " audio_status: " + mAudioMuted);
    if (mUidsList.size() == 0) {
        return;
    }

    SurfaceView surfaceV = getLocalView();
    ViewParent parent;
    if (surfaceV == null || (parent = surfaceV.getParent()) == null) {
        log.warn("onVoiceChatClicked " + view + " " + surfaceV);
        return;
    }

    RtcEngine rtcEngine = rtcEngine();
    mVideoMuted = !mVideoMuted;

    if (mVideoMuted) {
        rtcEngine.disableVideo();
    } else {
        rtcEngine.enableVideo();
    }

    ImageView iv = (ImageView) view;

    iv.setImageResource(mVideoMuted ? R.drawable.btn_video : R.drawable.btn_voice);

    hideLocalView(mVideoMuted);

    if (mVideoMuted) {
        resetToVideoDisabledUI();
    } else {
        resetToVideoEnabledUI();
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:35,代码来源:ChatActivity.java


注:本文中的io.agora.rtc.RtcEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。