tencent cloud

All product documents
User Generated Short Video SDK
Last updated: 2025-04-01 17:14:08
iOS
Last updated: 2025-04-01 17:14:08

Adding Background Music During Shooting

// Get the recorder instance
TXUGCRecord *recorder = [TXUGCRecord shareInstance];

// Set BGM file path
[recorder setBGMAsset:path];

// Set BGM using AVAsset loaded from the system media library
[recorder setBGMAsset:asset];

// Play BGM
[recorder playBGMFromTime:beginTime
toTime:endTime
withBeginNotify:^(NSInteger errCode) {
// Playback start callback. errCode 0: success, others: failure
} withProgressNotify:^(NSInteger progressMS, NSInteger durationMS) {
// progressMS: elapsed time (ms), durationMS: total duration (ms)
} andCompleteNotify:^(NSInteger errCode) {
// Playback complete callback. errCode 0: success, others: failure
}];

// Stop BGM playback
[recorder stopBGM];

// Pause BGM playback
[recorder pauseBGM];

// Resume BGM playback
[recorder resumeBGM];

// Set microphone volume (used during BGM mixing)
// volume: 1.0 is normal volume. Recommended range: 0-2. Higher values allowed for amplification.
[recorder setMicVolume:1.0];

// Set BGM volume (used during BGM mixing)
// volume: 1.0 is normal volume. Recommended range: 0-2. Higher values allowed for amplification.
[recorder setBGMVolume:1.0];
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon