峰哥,救救qwq
This commit is contained in:
34039
Assets/Scenes/UI 3.unity
Normal file
34039
Assets/Scenes/UI 3.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/UI 3.unity.meta
Normal file
7
Assets/Scenes/UI 3.unity.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c6bc7a7c08c4ff4c87ef46a822664f1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33464
Assets/Scenes/UI.unity
33464
Assets/Scenes/UI.unity
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@ public class UMPController : Singleton<UMPController>
|
||||
foreach (UniversalMediaPlayer player in opation.ump)
|
||||
{
|
||||
player.Play();
|
||||
player.GetComponent<UMPTool>().Init();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
21
Assets/Script/Tool/MediaPlayerTool.cs
Normal file
21
Assets/Script/Tool/MediaPlayerTool.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RenderHeads.Media.AVProVideo;
|
||||
using UnityEngine;
|
||||
|
||||
public class MediaPlayerTool : MonoBehaviour
|
||||
{
|
||||
public MediaPlayer m_MediaPlayer;
|
||||
public string deviceId;
|
||||
public string channelId;
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_MediaPlayer = GetComponent<MediaPlayer>();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
m_MediaPlayer.Play();
|
||||
}
|
||||
}
|
11
Assets/Script/Tool/MediaPlayerTool.cs.meta
Normal file
11
Assets/Script/Tool/MediaPlayerTool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeb25b0788f916744b93fd746f478aca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,25 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UMP;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using RenderHeads.Media.AVProVideo;
|
||||
using MediaPlayer = RenderHeads.Media.AVProVideo.MediaPlayer;
|
||||
|
||||
[RequireComponent(typeof(UniversalMediaPlayer))]
|
||||
public class UMPTool : MonoBehaviour
|
||||
{
|
||||
public string path;
|
||||
public Text Message;
|
||||
private UniversalMediaPlayer ump;
|
||||
|
||||
public UniversalMediaPlayer ump;
|
||||
public MediaPlayer mediaPlayer;
|
||||
public MediaPath mediaPath;
|
||||
|
||||
public string deviceId;
|
||||
public string channelId;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init() {
|
||||
public void Init()
|
||||
{
|
||||
/*
|
||||
Debug.Log(mediaPlayer.MediaPath.Path);
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
mediaPlayer.gameObject.SetActive(true);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
ump = GetComponent<UniversalMediaPlayer>();
|
||||
ump.Path = Application.streamingAssetsPath + path;
|
||||
// ump.Path = Application.streamingAssetsPath + path;
|
||||
ump.AddEncounteredErrorEvent(() => {
|
||||
Message.text = "当前链接失效!";
|
||||
Message.color = Color.red;
|
||||
@ -31,6 +44,8 @@ public class UMPTool : MonoBehaviour
|
||||
Message.text = "";
|
||||
ump.RenderingObjects[0].GetComponent<RawImage>().color = Color.white;
|
||||
});
|
||||
}
|
||||
|
||||
ump.Play();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
277
Assets/Script/Tool/VideoPlayerUrlTool.cs
Normal file
277
Assets/Script/Tool/VideoPlayerUrlTool.cs
Normal file
@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using RenderHeads.Media.AVProVideo;
|
||||
|
||||
public class VideoPlayerUrlTool : MonoBehaviour
|
||||
{
|
||||
public static VideoPlayerUrlTool instance;
|
||||
private string LiveStreamurl = "https://openapi.lechange.cn/openapi/getLiveStreamInfo";
|
||||
private string liveListurl = "http://139.224.250.209:18801/api/get_live_list"; //https://openapi.lechange.cn/openapi/liveList
|
||||
private string tokenurl = "http://139.224.250.209:18801/api/get_token"; // https://openapi.lechange.cn/openapi/accessToken
|
||||
private LCToken token;
|
||||
private string appID = "lc82079017516e4e87";
|
||||
private string appSecret = "91bf33ef0de14dc4b3c36c466e02f5";
|
||||
private long time;
|
||||
private string nonce;
|
||||
private string SIGN_TEMPLATE;
|
||||
private string sign;
|
||||
string tokenjsonData="";
|
||||
private string toKenData;
|
||||
private LCLiveListData listData;
|
||||
public LClives[] LClive;
|
||||
public UMPTool[] videos;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(ToKenPost());
|
||||
}
|
||||
|
||||
|
||||
public static string Encrypt(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input)) return string.Empty;
|
||||
|
||||
using (MD5 md5 = MD5.Create())
|
||||
{
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
|
||||
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hashBytes.Length; i++)
|
||||
{
|
||||
sb.Append(hashBytes[i].ToString("x2")); // 小写十六进制
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ToKenPost(){
|
||||
|
||||
UnityWebRequest uwr = new UnityWebRequest(tokenurl, "POST");
|
||||
uwr.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(tokenjsonData));
|
||||
uwr.downloadHandler = new DownloadHandlerBuffer();
|
||||
|
||||
//如果有请求头,根据具体字段要求设置
|
||||
uwr.SetRequestHeader("Content-Type", "application/json");
|
||||
uwr.SetRequestHeader("app-version", "V1");
|
||||
|
||||
yield return uwr.SendWebRequest();
|
||||
toKenData = JsonConvert.DeserializeObject<Ftoken>(uwr.downloadHandler.text).result.data.accessToken;
|
||||
|
||||
if (uwr.isHttpError || uwr.isNetworkError)
|
||||
{
|
||||
Debug.LogError("Login Error: " + uwr.error);
|
||||
}
|
||||
|
||||
StartCoroutine(FlvPost());
|
||||
}
|
||||
|
||||
IEnumerator FlvPost(){
|
||||
FGetlivelist getlivelist = new FGetlivelist();
|
||||
|
||||
getlivelist.token = toKenData;
|
||||
getlivelist.queryRange = "1-99";
|
||||
|
||||
|
||||
string listjsonData = JsonConvert.SerializeObject(getlivelist);
|
||||
|
||||
UnityWebRequest uwr = new UnityWebRequest(liveListurl, "POST");
|
||||
uwr.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(listjsonData));
|
||||
uwr.downloadHandler = new DownloadHandlerBuffer();
|
||||
|
||||
//如果有请求头,根据具体字段要求设置
|
||||
uwr.SetRequestHeader("Content-Type", "application/json");
|
||||
uwr.SetRequestHeader("app-version", "V1");
|
||||
|
||||
yield return uwr.SendWebRequest();
|
||||
|
||||
LCLiveListData flv = JsonConvert.DeserializeObject<LCLiveListData>(uwr.downloadHandler.text);
|
||||
LClive = flv.result.data.lives;
|
||||
|
||||
for (int i = 0; i < videos.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < LClive.Length; j++)
|
||||
{
|
||||
if (LClive[j].deviceId == videos[i].deviceId && LClive[j].channelId == videos[i].channelId)
|
||||
{
|
||||
videos[i].GetComponent<UMPTool>().mediaPlayer
|
||||
.OpenMedia(new MediaPath(LClive[j].streams[0].hls, MediaPathType.AbsolutePathOrURL));
|
||||
|
||||
// videos[i].GetComponent<UMPTool>().mediaPath =
|
||||
// new MediaPath(LClive[j].streams[0].hls, MediaPathType.AbsolutePathOrURL);
|
||||
videos[i].Init();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UMPController.Inst.UMPPlayer("页面一(首页)");
|
||||
|
||||
if (uwr.isHttpError || uwr.isNetworkError)
|
||||
{
|
||||
Debug.LogError("Login Error: " + uwr.error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LCSystem {
|
||||
public string ver;
|
||||
public string appId;
|
||||
public string sign;
|
||||
public long time;
|
||||
public string nonce;
|
||||
}
|
||||
|
||||
class LCGetToken{
|
||||
public LCSystem system;
|
||||
public string id;
|
||||
public string[] param;
|
||||
}
|
||||
|
||||
class lCresultData
|
||||
{
|
||||
public int expireTime;
|
||||
public string accessToken;
|
||||
}
|
||||
|
||||
class lCresult
|
||||
{
|
||||
public string msg;
|
||||
public string code;
|
||||
public lCresultData data;
|
||||
}
|
||||
|
||||
class LCToken
|
||||
{
|
||||
public lCresult result;
|
||||
public string id;
|
||||
}
|
||||
|
||||
class LCLiveListParam{
|
||||
public string token;
|
||||
public string queryRange;
|
||||
}
|
||||
|
||||
class LCLiveList
|
||||
{
|
||||
public LCSystem system;
|
||||
public string id;
|
||||
public LCLiveListParam param;
|
||||
}
|
||||
|
||||
public class LCsteam
|
||||
{
|
||||
public string coverUrl;
|
||||
public int streamId;
|
||||
public string hls;
|
||||
}
|
||||
|
||||
public class LCjob
|
||||
{
|
||||
public string period;
|
||||
public bool status;
|
||||
}
|
||||
|
||||
public class LClives
|
||||
{
|
||||
public int liveType;
|
||||
public int coverUpdate;
|
||||
public LCsteam[] streams;
|
||||
public string liveToken;
|
||||
public LCjob[] job;
|
||||
public string deviceId;
|
||||
public int liveStatus;
|
||||
public string channelId;
|
||||
}
|
||||
|
||||
class LCLiveresultData
|
||||
{
|
||||
public LClives[] lives;
|
||||
public int count;
|
||||
}
|
||||
|
||||
class LCliveResult
|
||||
{
|
||||
public string msg;
|
||||
public string code;
|
||||
public LCLiveresultData data;
|
||||
}
|
||||
|
||||
class LCLiveListData
|
||||
{
|
||||
public LCliveResult result;
|
||||
public string id;
|
||||
}
|
||||
|
||||
class LCLiveStreamParam
|
||||
{
|
||||
public string deviceId;
|
||||
public string channelId;
|
||||
public string token;
|
||||
}
|
||||
|
||||
class LCLiveStream
|
||||
{
|
||||
public LCSystem system;
|
||||
public string id;
|
||||
public LCLiveStreamParam param;
|
||||
}
|
||||
|
||||
class LCFlvresult
|
||||
{
|
||||
public string msg;
|
||||
public string code;
|
||||
public LCFlvdata data;
|
||||
}
|
||||
|
||||
class LCFlvdata
|
||||
{
|
||||
public string deviceId;
|
||||
public string channelId;
|
||||
public string flv;
|
||||
public string flvHD;
|
||||
}
|
||||
|
||||
class LCFlv
|
||||
{
|
||||
public LCFlvresult result;
|
||||
public string id;
|
||||
}
|
||||
|
||||
class Fdata
|
||||
{
|
||||
public string expireTime;
|
||||
public string accessToken;
|
||||
}
|
||||
|
||||
class Fresult
|
||||
{
|
||||
public string msg;
|
||||
public string code;
|
||||
public Fdata data;
|
||||
}
|
||||
|
||||
class Ftoken
|
||||
{
|
||||
public Fresult result;
|
||||
public string id;
|
||||
}
|
||||
|
||||
class FGetlivelist
|
||||
{
|
||||
public string token;
|
||||
public string queryRange;
|
||||
}
|
11
Assets/Script/Tool/VideoPlayerUrlTool.cs.meta
Normal file
11
Assets/Script/Tool/VideoPlayerUrlTool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef5f1c8dc535b20409ce65bbd76add01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29370
Assets/WebGLTemplates/DefaultTemplate/hls.min.js
vendored
Normal file
29370
Assets/WebGLTemplates/DefaultTemplate/hls.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/WebGLTemplates/DefaultTemplate/hls.min.js.meta
Normal file
7
Assets/WebGLTemplates/DefaultTemplate/hls.min.js.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9a823fd3b5f3c04b92aaaba21827458
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -24,6 +24,7 @@
|
||||
<div id="unity-fullscreen-button"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="hls.min.js"></script>
|
||||
<script>
|
||||
var container = document.querySelector("#unity-container");
|
||||
var canvas = document.querySelector("#unity-canvas");
|
||||
|
@ -8,6 +8,9 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/UI.unity
|
||||
guid: f5b5d1779de90c44fa0544ace683901b
|
||||
- enabled: 0
|
||||
path: Assets/Scenes/UI 3.unity
|
||||
guid: 4c6bc7a7c08c4ff4c87ef46a822664f1
|
||||
m_configObjects:
|
||||
com.unity.input.settings: {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7,
|
||||
type: 2}
|
||||
|
Reference in New Issue
Block a user