MediaContext
The MediaContext class.
- 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.
startRenderVideoFromCdn
Starts rendering the video stream from the CDN.
abstract fun startRenderVideoFromCdn( config: EduContextRenderConfig, container: ViewGroup, streamUrl: String, renderVideoListener: (() -> Unit)? = null )
Parameter
- config
- Video rendering configurations. See EduContextRenderConfig.
- container
- The view for rendering.
- streamUrl
- The CDN address.
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.
stopRenderVideoFromCdn
Stops rendering the video stream from the CDN.
Parameter
- streamUuid
- The stream ID.
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()
startPlayAudio
Starts playing the audio stream.
abstract fun startPlayAudio(roomUuid: String, streamUuid: String)
Parameter
- roomUuid
- The room ID.
- streamUuid
- The stream ID.
startPlayAudioFromCdn
Starts playing the audio stream from the CDN.
abstract fun startPlayAudioFromCdn(streamUrl: String, startPos: Long? = 0)
Parameter
- streamUuid
- The CDN address.
- startPos
- The playback position.
stopPlayAudio
Stops playing the audio stream.
abstract fun stopPlayAudio(roomUuid: String, streamUuid: String)
Parameter
- roomUuid
- The room ID.
- streamUuid
- The stream ID.
stopPlayAudioFromCdn
Stops playing the audio stream from the CDN.
abstract fun stopPlayAudioFromCdn(streamUrl: String)
Parameter
- streamUrl
- The CDN address.
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.
getSnapshot
Takes a snapshot from a video stream.
abstract fun getSnapshot( roomUuid: String, streamUuid: String, filePath: String, callback: EduContextCallback<FcrSnapshotInfo>? )
The snapshot is saved to the local folder that you specify in the JPG format. Wait for at least one second before you call this method for the second time.
Parameter
- roomUuid
- The room ID.
- streamUuid
- The stream ID.
- filePath
- The absolute path for saving the snapshot. The file path should include the file name, such as xxx/xxx/example.jpg.
- callback
- If the method call succeeds, the SDK returns the snapshot information FcrSnapshotInfo.
addAudioRawDataObserver
Registers a raw data observer for a position in the audio pipeline.
abstract fun addAudioRawDataObserver( observer: FcrMediaRawDataObserver, config: FcrAudioRawDataConfig? = FcrAudioRawDataConfig() )
Parameter
- observer
- The observer. See FcrAudioRawDataObserver.
- config
- The position in the audio pipeline. See FcrAudioRawDataConfig.
removeAudioRawDataObserver
Removes the raw data observer for a position in the audio pipeline.
abstract fun removeAudioRawDataObserver(observer: FcrMediaRawDataObserver)
Parameter
- observer
- The observer. See FcrAudioRawDataObserver.