MediaContext
The MediaContext class.
The methods provided by the MediaContext class are used for:
- Managing local audio and video devices.
- Playing local audio.
- Rendering and previewing local video.
getLocalDevices
Gets the local devices.
abstract fun getLocalDevices(deviceType: AgoraEduContextDeviceType): List<AgoraEduContextDeviceInfo>
Parameter
- deviceType
- The device type. See AgoraEduContextDeviceType.
Returns
An array of AgoraEduContextDeviceInfo.
openLocalDevice
Turns on the specified local device.
abstract fun openLocalDevice(deviceInfo: AgoraEduContextDeviceInfo, callback: EduContextCallback<Unit>? = null)
Parameter
- deviceInfo
- The device information. See AgoraEduContextDeviceInfo.
- callback
- Get the method call result asynchronously through EduContextCallback.
closeLocalDevice
Turns off the local device.
abstract fun closeLocalDevice(deviceInfo: AgoraEduContextDeviceInfo, callback: EduContextCallback<Unit>? = null)
Parameter
- deviceInfo
- The device information. See AgoraEduContextDeviceInfo.
- callback
- Get the method call result asynchronously through EduContextCallback.
getLocalDeviceState
Gets the state of the local device.
abstract fun getLocalDeviceState(deviceInfo: AgoraEduContextDeviceInfo, callback: EduContextCallback<AgoraEduContextDeviceState2>?)
Parameter
- deviceInfo
- The device information. See AgoraEduContextDeviceInfo.
- callback
- Get the device state AgoraEduContextDeviceState2 asynchronously through EduContextCallback.
startRenderLocalVideo
Starts rendering the video stream.
abstract fun startRenderLocalVideo(config: EduContextRenderConfig, container: ViewGroup, streamUuid: String)
Parameter
- config
- Video rendering configurations. See EduContextRenderConfig.
- container
- The view for rendering.
- streamUuid
- The ID of the stream to be rendered.
stopRenderLocalVideo
Stops rendering the video stream.
abstract fun stopRenderLocalVideo(streamUuid: String)
Parameter
- streamUuid
- The stream ID. If you want to stop previewing the video stream captured by the local camera before joining the room, set streamUuid as 0.
startAudioMixing
Starts audio mixing.
abstract fun startAudioMixing(filepath: String, loopback: Boolean, replace: Boolean, cycle: Int)
Call this method to mix the audio stream sampled by the microphone with the audio in the locally-played music file, so that the remote user can hear the music file more clearly.
Parameter
- filePath
- The path of the music file that needs to be mixed.
- loopback
- Whether to play the music file only on the local client.
- replace
- Whether to replace the audio sampled by the microphone with the music file.
- cycle
- The number of times the music file is played. Setting this parameter as -1 means loop playback.
stopAudioMixing
Stops audio mixing.
abstract fun stopAudioMixing()
setAudioMixingPosition
Sets the starting position of the music file for mixing.
abstract fun setAudioMixingPosition(position: Int)
Parameter
- position
- The starting position (in milliseconds) of the music file.
addAudioRawDataObserver
Registers an FcrAudioRawDataObserver.
abstract fun addAudioRawDataObserver( observer: FcrMediaRawDataObserver, config: FcrAudioRawDataConfig? = FcrAudioRawDataConfig() )
Parameter
- observer
- The audio raw data observer: FcrAudioRawDataObserver.
- config
- The output configuration of the audio pipeline: FcrAudioRawDataConfig。
removeAudioRawDataObserver
Unregisters the FcrAudioRawDataObserver.
abstract fun removeAudioRawDataObserver(observer: FcrMediaRawDataObserver)
参数
- observer
- The FcrAudioRawDataObserver.