admin管理员组

文章数量:1422160

安卓端录像并将视频分享给微信好友

ShareREC for unity (安卓)手游录制视频并分享给微信好友

1. 首先你需要在微信开放平台上申请一个移动应用 网址在下面 。申请应用是为了获取一个应用的AppID. 

应用签名的获取:创建一个空的项目,然后在下面这个地方创建一个keystore文件(如何创建请百度),

 

2. 注意:你的其他信息都要和最终应用的一样。包名之类的。

3. 然后打包出一个apk,在微信开放平台上下载一个签名生成工具(apk文件)。将这两个apk都导入到你的手机中同时运行,然后在签名生成工具中输入你的包名 

4. 注意一定要一样,然后会生成一个应用签名,该签名就是你申请应用的时候需要填写的应用签名。

5. 然后提交应用等待审核,差不多四天左右时间可以审核完成。

应用申请完成后你需要在mob官网上下载ShareREC这个插件。(这个插件里面包含的有分享功能,所以你不需要重新集成shareSDK,不过最好还是看一下你的里面有没有集成一些shareSDK的东西)。

将shareREC脚本挂在你的camera下面 并修改一些参数

Appkey和AppSecret是你在mob官网上免费申请的。

注意Record GUI Layer这个选项不要勾选,录制的时候不会把UI录制下来。

注意unity里面这个地方要修改成这个样子,否则的话录制会出问题。

接下来找到插件里面的ShareSDK文件然后修改这几个地方

 

将appid和appsecret改为你申请的  bypassapproval设置为false。

注意如果填错的话会分享失败。

最重要的地方是AndroidManifest文件  我的Manifest里面的信息是这样的

 

1 这个地方好像需要和你的包名一样,但是这个项目里面我没有改成一样的也打包成功了。

红线圈住的地方原本是没有的,我从另外一个文件里面粘贴过来的。2那个地方改成你的包名。

这一系列弄完以后应该就搞定了

附上我写的代码

using System.Collections;using System.Collections.Generic;using UnityEngine;using cn.sharerec;using UnityEngine.UI;public class shareManager : MonoBehaviour {bool started;public Text tishi1;public Text tishi2;// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {}public void OnStartButtonClick(){if (!ShareREC.IsAvailable()) return;tishi1.text = "点击了录制按钮";ShareREC.OnRecorderStartedHandler = onStarted;Debug.LogError(" RECClassic ================= StartRecorder 111 ");// 启动录制 (start recording)ShareREC.StartRecorder();}public void OnEndButtonClick(){if (!ShareREC.IsAvailable()) return;tishi1.text = "点击了结束录制按钮";// 设置停止监听 (add recorder stopped listener)ShareREC.OnRecorderStoppedHandler = onStopped;// 停止录制 (stop recording)ShareREC.StopRecorder();}public void OnProfileButtonClick(){if (!ShareREC.IsAvailable()) return;tishi1.text = "点击了个人中心";// 添加返回操作(add callback to handle returning operations)ShareREC.OnReturnFromProfileHandler = OnReturned;ShareREC.OnPlatformSelectedHandler = OnPlatformSelected;ShareREC.AddCustomPlatform("CustomPlatform");// 打开个人中心 (show user profile page)ShareREC.ShowProfile();}void onStarted(){Debug.Log("============== onStarted ");tishi2.text = "OnStarted";started = true;}void onStopped(){started = false;// 停止录制后启动分享视频 (show sharing page after the recorder is stopped)ShareREC.SetText("Angry Rebot");ShareREC.AddCustomAttr("score", "5000");ShareREC.AddCustomAttr("name", "ShareREC Developer");ShareREC.AddCustomAttr("brand", "hehe!");ShareREC.AddCustomAttr("level", "10");// 添加返回操作(add callback to handle returning operations)ShareREC.OnReturnFromShareHandler = OnReturned;ShareREC.OnPlatformSelectedHandler = OnPlatformSelected;ShareREC.AddCustomPlatform("CustomPlatform");ShareREC.ShowShare();}void OnReturned(){Debug.Log("============== I am BACK!!!!");tishi2.text = "i am back";}void OnPlatformSelected(string name, MP4 mp4){Debug.Log("menu \"" + name + "\" is selected");Debug.Log("video path:" + mp4.getLocalPath());}}



 

本文标签: 安卓端录像并将视频分享给微信好友