Class Publisher
- All Implemented Interfaces:
Observer
When the view of a Publisher leaves the active window, the Publisher object is destroyed. This is the case for an activity that is stopped or paused.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsed to build aPublisherobject.static enumDefines values for theframeRateparameter of thePublisher.Builder.frameRate(Publisher.CameraCaptureFrameRate frameRate)method.static enumDefines values for theresolutionparameter of thePublisher.Builder.resolution(Publisher.CameraCaptureResolution resolution)method.static interfaceMonitors when the camera used by the publisher changes.Nested classes/interfaces inherited from class com.opentok.android.PublisherKit
PublisherKit.AudioLevelListener, PublisherKit.AudioStatsListener, PublisherKit.AudioTransformer, PublisherKit.CustomAudioTransformer, PublisherKit.CustomVideoTransformer, PublisherKit.MuteListener, PublisherKit.PreferredVideoCodecs, PublisherKit.PublisherAudioStats, PublisherKit.PublisherKitVideoType, PublisherKit.PublisherListener, PublisherKit.PublisherRtcStats, PublisherKit.PublisherRtcStatsReportListener, PublisherKit.PublisherVideoStats, PublisherKit.VideoBitratePreset, PublisherKit.VideoListener, PublisherKit.VideoStatsListener, PublisherKit.VideoTransformer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Publisher.CameraCaptureFrameRateprotected Publisher.CameraListenerprotected Publisher.CameraCaptureResolutionFields inherited from class com.opentok.android.PublisherKit
audioLevelListener, audioStatsListener, capturer, context, handler, muteListener, publisherListener, renderer, rtcStatsReportListener, videoListener, videoStatsListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCycles between cameras, if there are multiple cameras on the device.intDeprecated.protected voidonCameraChanged(int newCameraId) Invoked when the publisher changes the active camera.protected voidonCameraError(OpentokError error) Invoked when there is an error accessing the camera.voidsetCameraId(int cameraId) Deprecated.voidsetCameraListener(Publisher.CameraListener listener) Sets aPublisher.CameraListenerobject to monitor when the camera used by the publisher changes.voidsetCameraTorch(boolean enable) Sets the preferred flashlight (torch) mode for the camera.voidsetCameraZoomFactor(float cameraZoomFactor) The preferred zoom factor (ratio) for the camera.voidDeprecated.voidDeprecated.Methods inherited from class com.opentok.android.PublisherKit
destroy, finalize, getAudioFallbackEnabled, getCapturer, getMaxVideoBitrate, getName, getPublishAudio, getPublishCaptions, getPublisherVideoType, getPublishVideo, getRenderer, getRtcStatsReport, getSession, getStream, getVideoBitratePreset, getView, onAudioLevelUpdated, onError, onMuteForced, onPause, onRestart, onResume, onRtcStatsReport, onStop, onStreamCreated, onStreamDestroyed, setAudioFallbackEnabled, setAudioLevelListener, setAudioStatsListener, setAudioTransformers, setCapturer, setMaxVideoBitrate, setMuteListener, setName, setPublishAudio, setPublishCaptions, setPublisherListener, setPublisherVideoType, setPublishVideo, setRenderer, setRtcStatsReportListener, setStyle, setVideoBitratePreset, setVideoListener, setVideoStatsListener, setVideoTransformers, update
-
Field Details
-
cameraFrameRate
-
cameraResolution
-
cameraListener
-
-
Constructor Details
-
Publisher
-
-
Method Details
-
setCameraListener
Sets aPublisher.CameraListenerobject to monitor when the camera used by the publisher changes.- Parameters:
listener- ThePublisher.CameraListenerinstance.
-
setCameraId
Deprecated.Sets the desired camera.cameraIdcan be a value between 0 and android.hardware.Camera#getNumberOfCameras() - 1.When the camera used by the Publisher changes, the
This method is deprecated. You should use the newPublisher.CameraListener.onCameraChanged(Publisher publisher, int newCameraId)method is called.cycleCamera()method to cycle between cameras, if there are multiple cameras on the device.- Parameters:
cameraId- the id of the camera you want to use on this publisher
-
setCameraTorch
public void setCameraTorch(boolean enable) Sets the preferred flashlight (torch) mode for the camera. Note that this is a preference and may not take effect if the active camera does not support flashlight functionality (for example, the front camera typically does not support a flashlight).- Parameters:
enable- The default value is false. Passing true or false indicates whether the publisher should enable or disable the camera's flashlight when available.
-
setCameraZoomFactor
public void setCameraZoomFactor(float cameraZoomFactor) The preferred zoom factor (ratio) for the camera. A value of 1.0 represents no zoom (the default view). The value ranges from 0.5 to the maximum zoom factor. Values between 0.5 and 1.0 represent ultra-wide-angle (zoom out) and values between 1.0 and the maximum zoom factor represent zooming in. The actual zoom factor applied is automatically clamped to the range supported by the active camera’s configuration — if the camera does not support ultra-wide-angle, zoom factors set below 1.0 will not take effect and no zoom will be applied. For values over the maximum zoom factor supported by the camera, the zoom factor will be set with the max value. If the publisher camera is enabled, getting this property returns the current zoom factor; if the publisher camera is not enabled, getting this property returns the preferred zoom factor.- Parameters:
cameraZoomFactor- Setting this property indicates the desired level of zoom, where a value of 1.0 represents no zoom (the default view).
-
cycleCamera
public void cycleCamera()Cycles between cameras, if there are multiple cameras on the device. When the camera used by the Publisher changes, thePublisher.CameraListener.onCameraChanged(Publisher publisher, int newCameraId)method is called. -
swapCamera
Deprecated.This method is deprecated. You should use the newcycleCamera()method to cycle between cameras, if there are multiple cameras on the device.If you are using a custom video capturer, implement the
BaseVideoCapturer.CaptureSwitchinterface in the object that extends BaseVideoCapturer, and implement theBaseVideoCapturer.CaptureSwitch.swapCamera(int cameraId)method to define the behavior of thePublisher.swapCamera()method. -
getCameraId
Deprecated.Returns the currently active camera ID. This value is either 0 (for the back-facing camera) or 1 (for the front-facing camera). IfsetCameraId(int)is never called, the return value is 1 (for the front-facing camera).This method is deprecated. You should use the new
cycleCamera()method to cycle between cameras, if there are multiple cameras on the device. -
onCameraChanged
protected void onCameraChanged(int newCameraId) Invoked when the publisher changes the active camera.If you extend the Publisher class, you can override this method instead of the
onCameraChanged()method of the Publisher.CameraListener interface.- Parameters:
newCameraId- The ID of the new active camera.
-
onCameraError
Invoked when there is an error accessing the camera.- Parameters:
error- The error.
-
startPreview
Deprecated.From version 2.17.0 on, this method doesn't do anything. As soon as the Publisher object is created the camera's video is displayed in the Publisher's view. This change makes the behaviour consistent across OpenTok client SDKs.
-