找不到LibVLCAttribute(UniversalMediaPlayer资产)

时间:2018-01-04 06:48:06

标签: c# android unity3d video-streaming libvlc

这有点长,所以请耐心等待。

我上周从Unity资源商店购买了一项资产,ump-pro-android-iosump-pro-win-mac-linux-webgl。我遵循将两种资产合二为一的规则。所以这就是事情。我有这个错误

  

异常:找不到LibVLCAttribute。   UMP.InteropLibraryLoader.GetInteropDelegate [libvlc_media_get_stats](IntPtr处理程序)(在Assets / UniversalMediaPlayer / Scripts / Sources / InteropLibraryLoader.cs:149)   Rethrow as MissingMethodException:函数的地址''在1721499648库中不存在。   UMP.InteropLibraryLoader.GetInteropDelegate [libvlc_media_get_stats](IntPtr处理程序)(在Assets / UniversalMediaPlayer / Scripts / Sources / InteropLibraryLoader.cs:173)   UMP.VlcMethods.LoadMethodsFromVLCLibrary(IntPtr处理程序)(在Assets / UniversalMediaPlayer / StreamingWork / VlcMethods.cs:59)   Rethrow as ArgumentException:在提供的路径中找不到合适的libvlc:函数的地址''在1721499648库中不存在。   参数名称:libvlcDirectory   UMP.VlcMethods.LoadMethodsFromVLCLibrary(IntPtr处理程序)(在Assets / UniversalMediaPlayer / StreamingWork / VlcMethods.cs:64)   UMP.VlcMethods..ctor()(在Assets / UniversalMediaPlayer / StreamingWork / VlcMethods.cs:41)   UMP.VlcMethods.get_Instance()(在Assets / UniversalMediaPlayer / StreamingWork / VlcMethods.cs:19)   DealerLiveCam + c__Iterator0.MoveNext()(在Assets / UniversalMediaPlayer / StreamingWork / DealerLiveCam.cs:201)   UnityEngine.SetupCoroutine.InvokeMoveNext(IEnumerator枚举器,IntPtr returnValueAddress)(在C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)   UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator的)   DealerLiveCam:OnPrepared(Texture2D)(在Assets / UniversalMediaPlayer / StreamingWork / DealerLiveCam.cs:154)   UnityEngine.Events.UnityEvent`1:调用(T0)   UniversalMediaPlayer:OnPlayerPrepared(Texture2D)(在Assets / UniversalMediaPlayer / Scripts / UniversalMediaPlayer.cs:1151)   UMP.PlayerManagerEvents:CallEvent()(在Assets / UniversalMediaPlayer / Scripts / Sources / Players / Managers / PlayerManagerEvents.cs:147)   UMP.c__Iterator0:MoveNext()(在Assets / UniversalMediaPlayer / Scripts / Sources / Players / Managers / PlayerManagerEvents.cs:118)   UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator,IntPtr)

这引导我进入资产脚本 InteropLibrary.cs

var attrs = typeof(T).GetCustomAttributes(typeof(InteropFunctionAttribute), false);
            if (attrs.Length == 0)
                throw new Exception("Could not find the LibVLCAttribute.");

VLCMETHOD.cs

using System;
using System.Runtime.InteropServices;
using UMP.Wrappers;

//http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc.html

namespace UMP
{
public class VlcMethods
{
    private static VlcMethods instance = null;
    public static VlcMethods Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new VlcMethods();
            }

            return instance;
        }
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate int libvlc_media_get_stats(IntPtr p_md, out libvlc_media_stats_t p_stats);
    public libvlc_media_get_stats Libvlc_media_get_stats;

    public VlcMethods()
    {
        var libraryExtension = string.Empty;
        var settings = UMPSettings.Instance;

        if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux && settings.UseExternalLibs)
            libraryExtension += ".5";

        IntPtr handler = InteropLibraryLoader.Load(Wrapper.LibraryVLCName, settings.UseExternalLibs, settings.AdditionalLibsPath, libraryExtension);
        if (handler != IntPtr.Zero)
        {
            LoadMethodsFromVLCLibrary(handler);
        }
    }

    ~VlcMethods()
    {
        instance = null;
    }

    private void LoadMethodsFromVLCLibrary(IntPtr handler)
    {
        if (handler == IntPtr.Zero)
            return;

        try
        {
            //Libvlc_media_get_stats = (libvlc_media_get_stats)InteropLibraryLoader.GetInteropDelegate<libvlc_media_get_stats>(handler);
            //[Pk Recode 29/12 2017]
            Libvlc_media_get_stats = InteropLibraryLoader.GetInteropDelegate<libvlc_media_get_stats>(handler);
        }
        catch (Exception exception)
        {
            InteropLibraryLoader.Unload(handler);
            throw new ArgumentException(
                String.Format("No suitable " + Wrapper.LIBRARY_VLC_NAME + " could be found in the provided path: {0}", exception.Message),
                Wrapper.LIBRARY_VLC_NAME + "Directory", exception);
        }
    }
}
}

当我在 PC 上构建它时,我的流媒体方法正在运行,当我在 Android 上试用它时它没有工作它告诉我 logcat的

  

NullReferenceException:未将对象引用设置为对象的实例                                             在UMP.MediaPlayer.set_Mute(布尔值)[0x00000]中:0                                             在UniversalMediaPlayer.OnPathPrepared(System.String path,Boolean playImmediately)[0x00000] in:0                                             在UniversalMediaPlayer + c__Iterator0.MoveNext()[0x00000] in:0                                             在UnityEngine.SetupCoroutine.InvokeMoveNext(IEnumerator枚举器,IntPtr returnValueAddress)[0x00000] in:0                                           UnityEngine.MonoBehaviour:StartCoroutine_Auto_Internal(IEnumerator的)                                           UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator的)                                           UniversalMediaPlayer:播放()                                           DealerLiveCamAndroid:更新()

以下是 DealerLiveCamAndroid.cs

上的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UMP;

public class DealerLiveCamAndroid : MonoBehaviour
{

[SerializeField]
GameObject ump; // lets access the ump gameobject
[SerializeField]
GameObject dealercam; //dealer cam for pc

void Update()
{
    if (tzPlayInfo.Instance.BLOCK_GAME_FLOW == false)
    {
        //find the gameobject through getting the child of every component/gameobject
        ump = this.gameObject.transform.GetChild(0).GetChild(1).GetChild(1).GetChild(1).GetChild(0).GetChild(1).gameObject;
        dealercam = this.gameObject.transform.GetChild(0).GetChild(1).GetChild(1).GetChild(1).GetChild(0).gameObject;

        if (ump != null && dealercam != null)
        {
            //deactivate the dealercam for pc
            //dealercam.GetComponent<DealerLiveCam>().enabled = false;
            //Uses an If directives for the platform dependencies
        #if UNITY_ANDROID

            ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform = 2;
            var path = "***********/live/DEALER";
            if (ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform == 2)
            {
                //set the path
                ump.GetComponent<UniversalMediaPlayer>()._path = path;
                Debug.Log("Path has been found : " + ump.GetComponent<UniversalMediaPlayer>()._path);
                ump.GetComponent<UniversalMediaPlayer>().Play();
                Debug.Log("Now Media Is Playing");
            }
            else
            {
                Debug.Log("Couldn't set the property to Android");
            }

        #elif UNITY_STANDALONE
            ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform = 0;
             //temporary path for the streaming
            var path = "rtmp://**********/live/DEALER";

            if(ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform == 0){
                Debug.Log("UMP property is set to StandAlone/Windows");
                ump.GetComponent<UniversalMediaPlayer>()._path = path;
                //set the Streaming to autoplay
                ump.GetComponent<UniversalMediaPlayer>().Play();
                this.enabled = false;
            } else {
                Debug.Log("Couldn't set the property to StandAlone/Windows");
            }
        #else
        #endif
        }
        else
        {
            Debug.Log("Could not get the gameobject UMP");
        }
    }
}
}

0 个答案:

没有答案