Release Notes
The “startPlay” API of the UGSV SDK Renamed
Class | Feature |
TXUGCRecord | Video shoot implementation |
TXUGCPartsManager | Video segment management class, which is used to shoot multiple video segments and delete existing segments |
ITXVideoRecordListener | Shoot callback |
TXRecordCommon | Basic parameter definition, including video shoot callback and release callback APIs |
TXUGCRecord mTXUGCRecord = TXUGCRecord.getInstance(context);// Create a TXCloudVideoView for camera previewmVideoView = (TXCloudVideoView) findViewById(R.id.video_view);// 1. Configure recording parameters (using recommended TXUGCSimpleConfig)TXRecordCommon.TXUGCSimpleConfig param = new TXRecordCommon.TXUGCSimpleConfig();param.videoQuality = TXRecordCommon.VIDEO_QUALITY_MEDIUM;// 2. Start camera previewmTXUGCRecord.startCameraSimplePreview(param, mVideoView);// 3. Set recording effects (example: add beauty filter)mTXUGCRecord.getBeautyManager().setBeautyStyle(TXBeautyManager.TXBeautyStyleSmooth);mTXUGCRecord.getBeautyManager().setBeautyLevel(5);// 4. Set recording event callback listenermTXUGCRecord.setVideoRecordListener(new ITXVideoRecordListener() {@Overridepublic void onRecordEvent(int eventId, Bundle bundle) {}@Overridepublic void onRecordProgress(long millisecond) {}@Overridepublic void onRecordComplete(TXRecordResult result) {}});// Start recordingint result = mTXUGCRecord.startRecord();// Stop recordingmTXUGCRecord.stopRecord();
TXUGCRecord (in TXUGCRecord.java) is used for short video shoot. The preview feature needs to be implemented first, where the startCameraSimplePreview function is used to start preview. As camera and mic need to be enabled before the preview can be started, prompt windows for permission application may pop up at this point.// Get the singleton instance of the recorderTXUGCRecord mTXUGCRecord = TXUGCRecord.getInstance(this.getApplicationContext());// Configure basic recording parametersTXRecordCommon.TXUGCSimpleConfig param = new TXRecordCommon.TXUGCSimpleConfig();param.videoQuality = TXRecordCommon.VIDEO_QUALITY_HIGH; // 720pparam.isFront = true; // Whether to use the front cameraparam.minDuration = 5000; // Minimum recording duration (ms)param.maxDuration = 60000; // Maximum recording duration (ms)param.touchFocus = false; // false: auto-focus; true: manual focus// Video preview viewmVideoView = (TXCloudVideoView) findViewById(R.id.video_view);// Start previewmTXUGCRecord.startCameraSimplePreview(param, mVideoView);// Stop camera previewmTXUGCRecord.stopCameraPreview();
// Switch video recording resolution to 540p (540x960)mTXUGCRecord.setVideoResolution(TXRecordCommon.VIDEO_RESOLUTION_540_960);// Switch video recording bitrate to 6500 KbpsmTXUGCRecord.setVideoBitrate(6500);// Get the maximum zoom level supported by the cameramTXUGCRecord.getMaxZoom();// Set zoom level to 3. Valid range: 0 ~ getMaxZoom()mTXUGCRecord.setZoom(3);// Switch camera: true for front camera, false for rear cameramTXUGCRecord.switchCamera(false);// Toggle flash: true to turn on, false to turn offmTXUGCRecord.toggleTorch(false);// When param.touchFocus is true (manual focus mode), use this API to set focus positionmTXUGCRecord.setFocusPosition(eventX, eventY);// Set custom video processing callbackmTXUGCRecord.setVideoProcessListener(this);
// Take a photo. Before calling this API, you must start the recording preview by calling either startCameraSimplePreview or startCameraCustomPreviewmTXUGCRecord.snapshot(new TXRecordCommon.ITXSnapshotListener() {@Overridepublic void onSnapshot(Bitmap bmp) {// Save or display the captured image}});
// Start recording// This method does not specify the recording file path. The path will be returned in the recording completion callback.mTXUGCRecord.startRecord();// Start recording with specified output video file path and cover image pathmTXUGCRecord.startRecord(videoFilePath, coverPath);// Start recording with specified output video file path, video segments folder path, and cover image pathmTXUGCRecord.startRecord(videoFilePath, videoPartFolder, coverPath);// Pause recordingmTXUGCRecord.pauseRecord();// Resume recordingmTXUGCRecord.resumeRecord();// Stop recordingmTXUGCRecord.stopRecord();
TXRecordCommon.ITXVideoRecordListener API (defined in TXRecordCommon.java):onRecordProgress returns the shoot progress, and the millisecond parameter indicates the shoot duration in milliseconds.@optionalvoid onRecordProgress(long milliSecond);
onRecordComplete returns the shoot result, the retCode and descMsg fields of TXRecordResult indicate the error code and error message, respectively, videoPath indicates the path of the shot short video file, and coverImage indicates the short video's first-frame image that is automatically captured and will be used in video release.@optionalvoid onRecordComplete(TXRecordResult result);
onRecordEvent is the shoot event callback, which contains the event ID and event-related parameters in the format of (key,value).@optionalvoid onRecordEvent(final int event, final Bundle param);
// Set orientation for preview// The valid values for `rotation` are 0, 90, 180, and 270, which indicate the clockwise rotation angle.// You must set the rotation before you call `startRecord` for the setting to take effect.mTXUGCRecord.setRenderRotation(TXLiveConstants.RENDER_ROTATION_PORTRAIT);// Set the aspect ratio// VIDEO_ASPECT_RATIO_9_16: 9:16// VIDEO_ASPECT_RATIO_3_4: 3:4// VIDEO_ASPECT_RATIO_1_1: 1:1// You must set the rotation before you call `startRecord` for the setting to take effect.mTXUGCRecord.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_9_16);
// Set the video shoot speed// TXRecordCommon.RECORD_SPEED_SLOWEST (ultra-slow)// TXRecordCommon.RECORD_SPEED_SLOW (slow)// TXRecordCommon.RECORD_SPEED_NORMAL (standard)// TXRecordCommon.RECORD_SPEED_FAST (fast)// TXRecordCommon.RECORD_SPEED_FASTEST (ultra-fast)mTXUGCRecord.setRecordSpeed(TXRecordCommon.VIDEO_RECORD_SPEED_NORMAL);
// Set the mic volume. This is used to control the volume of the mic when background music is mixed.// Volume. The normal volume is 1. We recommend 0-2, but you can set it to a larger value if you want louder music.mTXUGCRecord.setMicVolume(volume);// Mute/Unmute. The `isMute` parameter specifies whether to mute audio. Audio is unmuted by default.mTXUGCRecord.setMute(isMute);
// Add a global watermark// normalizationFrame: The normalized position of the watermark in relation to the video. The SDK calculates the watermark height based on the aspect ratio.// Suppose the video dimensions are 540 x 960, and `frame` is set to `(0.1,0.1,0.1, 0)`.// The actual coordinates of the watermark would be:// (540*0.1, 960*0.1, 540*0.1, 540*0.1*waterMarkImage.size.height / waterMarkImage.size.width)mTXUGCRecord.setWatermark(watermarkBitmap, txRect)
// Set the filter style// Set the color filter: Romantic, refreshing, elegant, pink, retro, and more// filterImage: The color lookup table, which must be in PNG format.// The color lookup table used in the demo is in `FilterResource.bundle`.mTXUGCRecord.setFilter(filterBitmap);// Set the strength of filters. Value range: 0-1. Default: 0.5. The greater the value, the stronger the filter.mTXUGCRecord.setSpecialRatio(0.5);// Set a filter combination// mLeftBitmap: The left filter// leftIntensity: The strength of the left filter// mRightBitmap: The right filter// rightIntensity: The strength of the right filter// leftRatio: The ratio of the width of the left picture to the video width// You can use this API to implement "swipe to change filter".mTXUGCRecord.setFilter(mLeftBitmap, leftIntensity, mRightBitmap, rightIntensity, leftRatio);
// Access Beauty Configuration InterfaceTXBeautyManager mTXBeautyManager = mTXCameraRecord.getBeautyManager();// Set beauty style: (TXBeautyStyleSmooth: Smooth; TXBeautyStyleNature: Natural; TXBeautyStylePitu: Pitu)mTXBeautyManager.setBeautyStyle(TXBeautyManager.TXBeautyStyleSmooth);// Set beauty level (0-9)mTXBeautyManager.setBeautyLevel(5);// Set whitening level (0-9)mTXBeautyManager.setWhitenessLevel(5);// Set rosy level (0-9)mTXBeautyManager.setRuddyLevel(5);
피드백