Skip to content

Commit

Permalink
【Mac】【demo】更新使用6.9.8341版本
Browse files Browse the repository at this point in the history
  • Loading branch information
rstru committed Jan 15, 2020
1 parent 0684010 commit d678d2b
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 46 deletions.
4 changes: 4 additions & 0 deletions Mac/TRTCDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

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

/* Begin PBXFileReference section */
129FE2EB23CEB3940028480C /* bgm_demo.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = bgm_demo.mp3; sourceTree = "<group>"; };
453167EF21E4555F007A91CB /* TRTCNewWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TRTCNewWindowController.m; sourceTree = "<group>"; };
453167F021E4555F007A91CB /* TRTCNewWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TRTCNewWindowController.xib; sourceTree = "<group>"; };
453167F121E4555F007A91CB /* TRTCNewWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TRTCNewWindowController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,6 +155,7 @@
D689A95221CC9AE400C7C618 /* TRTC */ = {
isa = PBXGroup;
children = (
129FE2EB23CEB3940028480C /* bgm_demo.mp3 */,
D697C3BF22F3164100E80A2A /* GenerateTestUserSig.h */,
D697C3C022F3164100E80A2A /* GenerateTestUserSig.m */,
45F96FC8223296E600E861EC /* TRTCApp.h */,
Expand Down Expand Up @@ -255,6 +258,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
129FE2EC23CEB3940028480C /* bgm_demo.mp3 in Resources */,
D689A93621CC97F400C7C618 /* Assets.xcassets in Resources */,
457A707E2200814E00DD193B /* TXCaptureSourceWindowController.xib in Resources */,
45AD957B21D656C2007B2EAF /* TRTCMainWindowController.xib in Resources */,
Expand Down
8 changes: 5 additions & 3 deletions Mac/TRTCDemo/TRTC/TRTCNewWindowController.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15702" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15702"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -117,7 +117,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tjR-ya-ddi">
<rect key="frame" x="89" y="87" width="62" height="18"/>
<rect key="frame" x="209" y="88" width="62" height="18"/>
<buttonCell key="cell" type="check" title="仅语音" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="joh-kt-Bu2">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -134,6 +134,8 @@
<constraint firstItem="DKF-2d-TZ5" firstAttribute="centerX" secondItem="vf1-hy-L5J" secondAttribute="centerX" id="CA3-7c-eha"/>
<constraint firstItem="EsP-0c-S1G" firstAttribute="centerX" secondItem="DKF-2d-TZ5" secondAttribute="centerX" id="CgI-P5-z0q"/>
<constraint firstItem="x4i-Wq-ShC" firstAttribute="centerX" secondItem="vf1-hy-L5J" secondAttribute="centerX" id="D5U-KX-fbW"/>
<constraint firstItem="tjR-ya-ddi" firstAttribute="centerX" secondItem="rec-2n-9wR" secondAttribute="centerX" id="G2r-aR-pes"/>
<constraint firstItem="tjR-ya-ddi" firstAttribute="top" secondItem="gvQ-jw-adu" secondAttribute="bottom" constant="24" id="IPD-jX-en8"/>
<constraint firstItem="DKF-2d-TZ5" firstAttribute="top" secondItem="vf1-hy-L5J" secondAttribute="top" constant="18" id="Zpt-61-GGv"/>
<constraint firstItem="EsP-0c-S1G" firstAttribute="top" secondItem="DKF-2d-TZ5" secondAttribute="bottom" id="ddN-Ki-Hyq"/>
<constraint firstItem="le9-4n-vSu" firstAttribute="centerY" secondItem="x4i-Wq-ShC" secondAttribute="centerY" id="gbk-7s-n5y"/>
Expand Down
6 changes: 6 additions & 0 deletions Mac/TRTCDemo/TRTC/TRTCSettingWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ typedef NS_ENUM(NSUInteger, TXAVSettingTabIndex) {
@property (weak) IBOutlet NSLevelIndicator *speakerVolumeMeter;
// 分享按钮
@property (weak) IBOutlet NSButton *shareButton;
// 设置BGM播放音量
@property (strong) IBOutlet NSSlider *BGMVolumeSlider;
// 设置BGM远端播放音量
@property (strong) IBOutlet NSSlider *BGMPublishVolumeSlider;
// 设备BGM本地播放音量
@property (strong) IBOutlet NSSlider *BGMPlayoutVolumeSlider;

// For Cocoa Bindings
// 推流设置
Expand Down
57 changes: 43 additions & 14 deletions Mac/TRTCDemo/TRTC/TRTCSettingWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// 用于对视频通话的分辨率、帧率和流畅模式进行调整,并支持记录下这些设置项

#import "TRTCSettingWindowController.h"
#import "GenerateTestUserSig.h"
#import <objc/message.h>
#import <CommonCrypto/CommonCrypto.h>

Expand Down Expand Up @@ -521,6 +522,43 @@ - (IBAction)onClickSpeakerTest:(NSButton *)sender {
}
}

- (IBAction)onPlayBGM:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"bgm_demo" ofType:@"mp3"];

[self.trtcEngine setBGMVolume:(self.BGMVolumeSlider.floatValue * 100)];
[self.trtcEngine setBGMPublishVolume:(self.BGMPublishVolumeSlider.floatValue * 100)];
[self.trtcEngine setBGMPlayoutVolume:(self.BGMPlayoutVolumeSlider.floatValue * 100)];

[self.trtcEngine playBGM:path withBeginNotify:^(NSInteger errCode) {

} withProgressNotify:^(NSInteger progressMS, NSInteger durationMS) {

} andCompleteNotify:^(NSInteger errCode) {

}];
}

- (IBAction)onStopBGM:(id)sender {
[self.trtcEngine stopBGM];
}

- (IBAction)onSetBGMVolume:(id)sender {
NSSlider *slider = sender;
[self.trtcEngine setBGMVolume:(slider.floatValue * 100)];
self.BGMPublishVolumeSlider.floatValue = slider.floatValue;
self.BGMPlayoutVolumeSlider.floatValue = slider.floatValue;
}

- (IBAction)onSetBGMPublishVolume:(id)sender {
NSSlider *slider = sender;
[self.trtcEngine setBGMPublishVolume:(slider.floatValue * 100)];
}

- (IBAction)onSetBGMPlayoutVolume:(id)sender {
NSSlider *slider = sender;
[self.trtcEngine setBGMPlayoutVolume:(slider.floatValue * 100)];
}

// 更改流控模式,流畅还是清晰
- (IBAction)onClickQOSPreference:(NSButton *)sender {
TRTCVideoQosPreference preference = sender.tag == 0 ? TRTCVideoQosPreferenceSmooth : TRTCVideoQosPreferenceClear;
Expand All @@ -544,26 +582,17 @@ - (IBAction)onClickShowCloudMixURL:(NSButton *)sender {
return;
}

NSString* streamId = [NSString stringWithFormat:@"%@_%@_main", self.roomID, self.userID] ;
const char *cStr = [streamId UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(cStr, (uint32_t)strlen(cStr), result);
NSString *md5StreamId = [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]
];


NSString* playUrl = [NSString stringWithFormat:@"http://3891.liveplay.myqcloud.com/live/3891_%@.flv", md5StreamId];
NSString* streamId = [NSString stringWithFormat:@"%@_%@_%@_main", @(_SDKAppID), self.roomID, self.userID];
NSString* playUrl = [NSString stringWithFormat:@"http://3891.liveplay.myqcloud.com/live/%@.flv", streamId];

NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:@[playUrl]];
picker.delegate = self;
[picker showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSRectEdgeMaxX];
/* NSAlert *alert = [[NSAlert alloc] init];

NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"混流地址";
alert.informativeText = playUrl;
[alert runModal];*/
[alert runModal];
}
#pragma mark - NSSharingServicePickerDelegate
- (NSArray<NSSharingService *> *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker sharingServicesForItems:(NSArray *)items proposedSharingServices:(NSArray<NSSharingService *> *)proposedServices
Expand Down
Loading

0 comments on commit d678d2b

Please sign in to comment.