Skip to content

Commit d678d2b

Browse files
committed
【Mac】【demo】更新使用6.9.8341版本
1 parent 0684010 commit d678d2b

6 files changed

+154
-46
lines changed

Mac/TRTCDemo.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
129FE2EC23CEB3940028480C /* bgm_demo.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 129FE2EB23CEB3940028480C /* bgm_demo.mp3 */; };
1011
453167F221E45560007A91CB /* TRTCNewWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 453167EF21E4555F007A91CB /* TRTCNewWindowController.m */; };
1112
453167F321E45560007A91CB /* TRTCNewWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 453167F021E4555F007A91CB /* TRTCNewWindowController.xib */; };
1213
457A707B2200814E00DD193B /* CaptureSourceCollectionItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = 457A70702200814D00DD193B /* CaptureSourceCollectionItem.xib */; };
@@ -34,6 +35,7 @@
3435
/* End PBXBuildFile section */
3536

3637
/* Begin PBXFileReference section */
38+
129FE2EB23CEB3940028480C /* bgm_demo.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = bgm_demo.mp3; sourceTree = "<group>"; };
3739
453167EF21E4555F007A91CB /* TRTCNewWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TRTCNewWindowController.m; sourceTree = "<group>"; };
3840
453167F021E4555F007A91CB /* TRTCNewWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TRTCNewWindowController.xib; sourceTree = "<group>"; };
3941
453167F121E4555F007A91CB /* TRTCNewWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TRTCNewWindowController.h; sourceTree = "<group>"; };
@@ -153,6 +155,7 @@
153155
D689A95221CC9AE400C7C618 /* TRTC */ = {
154156
isa = PBXGroup;
155157
children = (
158+
129FE2EB23CEB3940028480C /* bgm_demo.mp3 */,
156159
D697C3BF22F3164100E80A2A /* GenerateTestUserSig.h */,
157160
D697C3C022F3164100E80A2A /* GenerateTestUserSig.m */,
158161
45F96FC8223296E600E861EC /* TRTCApp.h */,
@@ -255,6 +258,7 @@
255258
isa = PBXResourcesBuildPhase;
256259
buildActionMask = 2147483647;
257260
files = (
261+
129FE2EC23CEB3940028480C /* bgm_demo.mp3 in Resources */,
258262
D689A93621CC97F400C7C618 /* Assets.xcassets in Resources */,
259263
457A707E2200814E00DD193B /* TXCaptureSourceWindowController.xib in Resources */,
260264
45AD957B21D656C2007B2EAF /* TRTCMainWindowController.xib in Resources */,

Mac/TRTCDemo/TRTC/TRTCNewWindowController.xib

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15702" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15505"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15702"/>
66
<capability name="Named colors" minToolsVersion="9.0"/>
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
@@ -117,7 +117,7 @@
117117
</textFieldCell>
118118
</textField>
119119
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tjR-ya-ddi">
120-
<rect key="frame" x="89" y="87" width="62" height="18"/>
120+
<rect key="frame" x="209" y="88" width="62" height="18"/>
121121
<buttonCell key="cell" type="check" title="仅语音" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="joh-kt-Bu2">
122122
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
123123
<font key="font" metaFont="system"/>
@@ -134,6 +134,8 @@
134134
<constraint firstItem="DKF-2d-TZ5" firstAttribute="centerX" secondItem="vf1-hy-L5J" secondAttribute="centerX" id="CA3-7c-eha"/>
135135
<constraint firstItem="EsP-0c-S1G" firstAttribute="centerX" secondItem="DKF-2d-TZ5" secondAttribute="centerX" id="CgI-P5-z0q"/>
136136
<constraint firstItem="x4i-Wq-ShC" firstAttribute="centerX" secondItem="vf1-hy-L5J" secondAttribute="centerX" id="D5U-KX-fbW"/>
137+
<constraint firstItem="tjR-ya-ddi" firstAttribute="centerX" secondItem="rec-2n-9wR" secondAttribute="centerX" id="G2r-aR-pes"/>
138+
<constraint firstItem="tjR-ya-ddi" firstAttribute="top" secondItem="gvQ-jw-adu" secondAttribute="bottom" constant="24" id="IPD-jX-en8"/>
137139
<constraint firstItem="DKF-2d-TZ5" firstAttribute="top" secondItem="vf1-hy-L5J" secondAttribute="top" constant="18" id="Zpt-61-GGv"/>
138140
<constraint firstItem="EsP-0c-S1G" firstAttribute="top" secondItem="DKF-2d-TZ5" secondAttribute="bottom" id="ddN-Ki-Hyq"/>
139141
<constraint firstItem="le9-4n-vSu" firstAttribute="centerY" secondItem="x4i-Wq-ShC" secondAttribute="centerY" id="gbk-7s-n5y"/>

Mac/TRTCDemo/TRTC/TRTCSettingWindowController.h

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ typedef NS_ENUM(NSUInteger, TXAVSettingTabIndex) {
9797
@property (weak) IBOutlet NSLevelIndicator *speakerVolumeMeter;
9898
// 分享按钮
9999
@property (weak) IBOutlet NSButton *shareButton;
100+
// 设置BGM播放音量
101+
@property (strong) IBOutlet NSSlider *BGMVolumeSlider;
102+
// 设置BGM远端播放音量
103+
@property (strong) IBOutlet NSSlider *BGMPublishVolumeSlider;
104+
// 设备BGM本地播放音量
105+
@property (strong) IBOutlet NSSlider *BGMPlayoutVolumeSlider;
100106

101107
// For Cocoa Bindings
102108
// 推流设置

Mac/TRTCDemo/TRTC/TRTCSettingWindowController.m

+43-14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// 用于对视频通话的分辨率、帧率和流畅模式进行调整,并支持记录下这些设置项
1010

1111
#import "TRTCSettingWindowController.h"
12+
#import "GenerateTestUserSig.h"
1213
#import <objc/message.h>
1314
#import <CommonCrypto/CommonCrypto.h>
1415

@@ -521,6 +522,43 @@ - (IBAction)onClickSpeakerTest:(NSButton *)sender {
521522
}
522523
}
523524

525+
- (IBAction)onPlayBGM:(id)sender {
526+
NSString *path = [[NSBundle mainBundle] pathForResource:@"bgm_demo" ofType:@"mp3"];
527+
528+
[self.trtcEngine setBGMVolume:(self.BGMVolumeSlider.floatValue * 100)];
529+
[self.trtcEngine setBGMPublishVolume:(self.BGMPublishVolumeSlider.floatValue * 100)];
530+
[self.trtcEngine setBGMPlayoutVolume:(self.BGMPlayoutVolumeSlider.floatValue * 100)];
531+
532+
[self.trtcEngine playBGM:path withBeginNotify:^(NSInteger errCode) {
533+
534+
} withProgressNotify:^(NSInteger progressMS, NSInteger durationMS) {
535+
536+
} andCompleteNotify:^(NSInteger errCode) {
537+
538+
}];
539+
}
540+
541+
- (IBAction)onStopBGM:(id)sender {
542+
[self.trtcEngine stopBGM];
543+
}
544+
545+
- (IBAction)onSetBGMVolume:(id)sender {
546+
NSSlider *slider = sender;
547+
[self.trtcEngine setBGMVolume:(slider.floatValue * 100)];
548+
self.BGMPublishVolumeSlider.floatValue = slider.floatValue;
549+
self.BGMPlayoutVolumeSlider.floatValue = slider.floatValue;
550+
}
551+
552+
- (IBAction)onSetBGMPublishVolume:(id)sender {
553+
NSSlider *slider = sender;
554+
[self.trtcEngine setBGMPublishVolume:(slider.floatValue * 100)];
555+
}
556+
557+
- (IBAction)onSetBGMPlayoutVolume:(id)sender {
558+
NSSlider *slider = sender;
559+
[self.trtcEngine setBGMPlayoutVolume:(slider.floatValue * 100)];
560+
}
561+
524562
// 更改流控模式,流畅还是清晰
525563
- (IBAction)onClickQOSPreference:(NSButton *)sender {
526564
TRTCVideoQosPreference preference = sender.tag == 0 ? TRTCVideoQosPreferenceSmooth : TRTCVideoQosPreferenceClear;
@@ -544,26 +582,17 @@ - (IBAction)onClickShowCloudMixURL:(NSButton *)sender {
544582
return;
545583
}
546584

547-
NSString* streamId = [NSString stringWithFormat:@"%@_%@_main", self.roomID, self.userID] ;
548-
const char *cStr = [streamId UTF8String];
549-
unsigned char result[CC_MD5_DIGEST_LENGTH];
550-
CC_MD5(cStr, (uint32_t)strlen(cStr), result);
551-
NSString *md5StreamId = [NSString stringWithFormat:
552-
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
553-
result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
554-
result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]
555-
];
556-
557-
558-
NSString* playUrl = [NSString stringWithFormat:@"http://3891.liveplay.myqcloud.com/live/3891_%@.flv", md5StreamId];
585+
NSString* streamId = [NSString stringWithFormat:@"%@_%@_%@_main", @(_SDKAppID), self.roomID, self.userID];
586+
NSString* playUrl = [NSString stringWithFormat:@"http://3891.liveplay.myqcloud.com/live/%@.flv", streamId];
559587

560588
NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:@[playUrl]];
561589
picker.delegate = self;
562590
[picker showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSRectEdgeMaxX];
563-
/* NSAlert *alert = [[NSAlert alloc] init];
591+
592+
NSAlert *alert = [[NSAlert alloc] init];
564593
alert.messageText = @"混流地址";
565594
alert.informativeText = playUrl;
566-
[alert runModal];*/
595+
[alert runModal];
567596
}
568597
#pragma mark - NSSharingServicePickerDelegate
569598
- (NSArray<NSSharingService *> *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker sharingServicesForItems:(NSArray *)items proposedSharingServices:(NSArray<NSSharingService *> *)proposedServices

0 commit comments

Comments
 (0)