MHUI 是开源的。英文界面和中文界面所用的文件名称不同,功能是一样的.菜单使用默认美颜方法如下(MHUI is open source. The English interface and the Chinese interface use different file names and have the same functions The default beauty method used in the menu is as follows:):
1) 在直播或者视频页面中添加美颜功能(Add beauty function in live broadcast or video page)
```
#import <MHBeautySDK/MHBeautyManager.h>
#import "MHBeautyParams.h"
#import "MHMeiyanMenusView.h"
(EnglishVersion is #import "BeautyFoxMenusView.h")
```
2) 声明属性
```
@property(nonatomic, strong)MHMeiyanMenusView *menusV
iew; (@property (nonatomic, strong) BeautyFoxMenusView *menusView;)
@property(nonatomic, strong)MHBeautyManager *beautyMana
ger;
```
3) 初始化美颜管理器(Initialize Beauty Manager)
\- (MHBeautyManager \*)beautyManager {
if (!\_beautyManager) {
\_beautyManager = \[\[MHBeautyManager alloc\] init\];
\_beautyManager.maxFace = 3;
}
return \_beautyManager;
}
4) 初始化美颜菜单(Initialize beauty menu)
/// 初始化美颜菜单(推荐使用)
/// @param frame frame
/// @param superView 所要添加到的视图
/// @param manager 美颜管理器,完成初始化后传入
/// 该方法默认使用美狐相关功能,不需要实现MHMeiyanMenusViewDelegate中的美颜方法
\- (instancetype)initWithFrame:(CGRect)frame superView:(UIView \*)superView beautyManager:(MHBeautyManager \*)manager;
EnhlisjVersion:
///(Initialize beauty menu,Recommand to use)
/// @param frame frame
/// @param superView
/// @param manager Pass in after initialization
/// This method uses the relevant functions of Meihu by default
\- (instancetype)initWithFrame:(CGRect)frame superView:(UIView \*)superView beautyManager:(MHBeautyManager \*)manager;
5) 初始化美颜菜单页实例(Initialize beauty menu page instance)
\- (MHMeiyanMenusView \*)menusView {
if (!\_menusView) {
\_menusView = \[\[MHMeiyanMenusView alloc\] initWithFrame:CGRectMake(0, window\_height - MHMeiyanMenuHeight - BottomIndicatorHeight, window\_width, MHMeiyanMenuHeight) superView:self.view beautyManager:self.beautyManager\];
}
return \_menusView;
}
6) 如果需要实现代理方法,则遵循协议MHMeiyanMenusViewDelegate , (BeautyFoxMenusViewDelegate)
7) 展示美颜页面,(Show beauty page):
\[self.menusView showMenuView:YES\];
8) 美颜菜单的隐藏,则可以在控制器的 touchesBegan
方法中调用上面的方法。示例代码(the beauty menu can be hidden in the touchesbegan of the controller
The above method is invoked in the method. Sample code):
\- (void)touchesBegan:(NSSet<UITouch \*> \*)touches
withEvent:(UIEvent \*)event{
if (self.menusView.isShow) {
\[self.menusView showMenuView:NO\];
if (!\[self.menusView isDescendantOfView:self.view\]) {
//页面上其他控件显示,根据自己的项目完善
}
}
}
9) 如果不想隐藏美颜菜单,可以在 touchesBegan 方法中调用 (If you don't want to hide the beauty menu, you can call it in the touchesBegan method.)
\[self.menusView showMenuView:YES\];
如果项目中有需求是调用保存的美颜效果,调用下面的方法。详情请看 MHMeiyanMenusView.m(If the demand in the project is to call the saved beauty effect, call the following method. For details, please see MHMeiyanMenusView.m)
-(void)setupDefaultBeautyAndFaceValue;
在渲染方法中调用,要设置标志符保证该方法只走一次,不
然耗内存,(In the rendering method, we need to set the identifier to ensure that the method will go only once.
Ran out of memory):
\- (GLuint)onPreProcessTexture:(GLuint)texture
width:(CGFloat)width height:(CGFloat)height
{
\[self.beautyManager processWithTexture:texture
width:width height:height\];
if (!self.isSetDefaultValue) {
\[self.menusView
setupDefaultBeautyAndFaceValue\];
self.isSetDefaultValue = YES;
}
return texture;
}
10) 渲染结束,要释放渲染资源,否则会造成内存泄漏(At the end of rendering, the rendering resources should be released, otherwise it will cause memory leakage)
\- (void)dealloc {
if (\_beautyManager) {
\[\_beautyManager destroy\];
\_beautyManager = nil;
}
}
以下是不同厂商的直播/短视频 SDK 的调用渲染方法(The following is the call rendering method of live / short video SDKs from different manufacturers):
- 美狐SDK接入文档
- Meihu SDK Access Document
- (Untitled)
- 一、基础描述(Basic description)
- 1. 最新特性 (Latest features)
- 2. 支持平台 (Support platform)
- 二、集成步骤 (Integration steps)
- 3. 配置工程(Configuration Engineering)
- 4. 使用 MHUI (Use MHUI)
- 5. 腾讯直播 SDK/短视频SDK (Tencent live SDK / short video SDK)
- 6. 金山直播SDK (Jinshan)
- 7. 七牛直播SDK (Qiniu Live)
- 8. 七牛短视频SDK (Qiniu ShortVideo)
- 9. Movieous短视频 (Movieous short Video)
- 10. 即构直播SDK (Zego live)
- 11. 即构实时音视频SDK(Zego Real time audio and video)
- 12. 新版Zego(即构)实时音视频(New Zego Real time audio and video)
- 13. 网易直播 (NetEase live)
- 14. 腾讯互动直播 (Tencent interactive live broadcast)
- 15. 腾讯实时音视频(Tencent real-time audio and video)
- 16. 融云实时音视频 (SealRTC)
- 17. 声网视频通话 (Agora video call)
- 18. 声网直播 (Agora Live)
- 19. 阿里直播 (Ali Live)
- 20. 阿里音视频 SDK美颜
- 三、对接说明 (Docking instructions)
- 四、常见问题(common problem)
- 2. 美颜无效果(Beauty has no effect)
- 3. 贴纸下载失败(Sticker download failed)
- 4. 点击无法出现美颜菜单页(The beauty menu page cannot appear after clicking)
- 5. 英文版显示中文(The beauty menu page cannot appear after clicking)
- 6. 语言切换功能(Language switching function)