Web报错:路径问题
This commit is contained in:
@ -3,375 +3,375 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace UMP.Wrappers
|
||||
{
|
||||
internal class WrapperInternal : IWrapperNative, IWrapperPlayer
|
||||
{
|
||||
#region iOS/WebGL Imports
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
private int _nativeIndex;
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr UMPNativeInit();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeInitPlayer(int index, string options);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeUpdateTexture(int index, IntPtr texture);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr UMPNativeGetTexturePointer(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeSetPixelsBuffer(int index, IntPtr buffer, int width, int height);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeUpdateFrameBuffer(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetDataSource(int index, string path);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPPlay(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPPause(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPStop(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPRelease(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPIsPlaying(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPIsReady(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetLength(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetTime(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetTime(int index, int time);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern float UMPGetPosition(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetPosition(int index, float position);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern float UMPGetRate(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetRate(int index, float rate);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetVolume(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetVolume(int index, int volume);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPGetMute(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetMute(int index, bool state);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPVideoWidth(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPVideoHeight(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPVideoFrameCount(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetState(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern float UMPGetStateFloatValue(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern long UMPGetStateLongValue(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr UMPGetStateStringValue(int index);
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public WrapperInternal(PlayerOptionsIPhone options)
|
||||
internal class WrapperInternal : IWrapperNative, IWrapperPlayer
|
||||
{
|
||||
#region iOS/WebGL Imports
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
_nativeIndex = (int)UMPNativeInit();
|
||||
#endif
|
||||
}
|
||||
private int _nativeIndex;
|
||||
|
||||
#region Native
|
||||
public int NativeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr UMPNativeInit();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeInitPlayer(int index, string options);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeUpdateTexture(int index, IntPtr texture);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr UMPNativeGetTexturePointer(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeSetPixelsBuffer(int index, IntPtr buffer, int width, int height);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPNativeUpdateFrameBuffer(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetDataSource(int index, string path);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPPlay(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPPause(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPStop(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPRelease(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPIsPlaying(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPIsReady(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetLength(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetTime(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetTime(int index, int time);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern float UMPGetPosition(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetPosition(int index, float position);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern float UMPGetRate(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetRate(int index, float rate);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetVolume(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetVolume(int index, int volume);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool UMPGetMute(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UMPSetMute(int index, bool state);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPVideoWidth(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPVideoHeight(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPVideoFrameCount(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int UMPGetState(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern float UMPGetStateFloatValue(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern long UMPGetStateLongValue(int index);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr UMPGetStateStringValue(int index);
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public WrapperInternal(PlayerOptionsIPhone options)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
return _nativeIndex;
|
||||
_nativeIndex = (int)UMPNativeInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
#region Native
|
||||
public int NativeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
return _nativeIndex;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void NativeInitPlayer(string options)
|
||||
{
|
||||
public void NativeInitPlayer(string options)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
UMPNativeInitPlayer(_nativeIndex, options);
|
||||
UMPNativeInitPlayer(_nativeIndex, options);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public IntPtr NativeGetTexture()
|
||||
{
|
||||
public IntPtr NativeGetTexture()
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
return UMPNativeGetTexturePointer(_nativeIndex);
|
||||
return UMPNativeGetTexturePointer(_nativeIndex);
|
||||
#else
|
||||
return IntPtr.Zero;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void NativeUpdateTexture(IntPtr texture)
|
||||
{
|
||||
public void NativeUpdateTexture(IntPtr texture)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
UMPNativeUpdateTexture(_nativeIndex, texture);
|
||||
UMPNativeUpdateTexture(_nativeIndex, texture);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void NativeSetPixelsBuffer(IntPtr buffer, int width, int height)
|
||||
{
|
||||
public void NativeSetPixelsBuffer(IntPtr buffer, int width, int height)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
UMPNativeSetPixelsBuffer(_nativeIndex, buffer, width, height);
|
||||
UMPNativeSetPixelsBuffer(_nativeIndex, buffer, width, height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void NativeUpdatePixelsBuffer()
|
||||
{
|
||||
public void NativeUpdatePixelsBuffer()
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
UMPNativeUpdateFrameBuffer(_nativeIndex);
|
||||
UMPNativeUpdateFrameBuffer(_nativeIndex);
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Player
|
||||
public void PlayerSetDataSource(string path, object playerObject = null)
|
||||
{
|
||||
#region Player
|
||||
public void PlayerSetDataSource(string path, object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetDataSource(_nativeIndex, path);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetDataSource(_nativeIndex, path);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public bool PlayerPlay(object playerObject = null)
|
||||
{
|
||||
public bool PlayerPlay(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
return UMPPlay(_nativeIndex);
|
||||
return UMPPlay(_nativeIndex);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerPause(object playerObject = null)
|
||||
{
|
||||
public void PlayerPause(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPPause(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPPause(_nativeIndex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerStop(object playerObject = null)
|
||||
{
|
||||
public void PlayerStop(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPStop(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPStop(_nativeIndex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerRelease(object playerObject = null)
|
||||
{
|
||||
public void PlayerRelease(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPRelease(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPRelease(_nativeIndex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public bool PlayerIsPlaying(object playerObject = null)
|
||||
{
|
||||
public bool PlayerIsPlaying(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPIsPlaying(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPIsPlaying(_nativeIndex);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool PlayerIsReady(object playerObject = null)
|
||||
{
|
||||
public bool PlayerIsReady(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPIsReady(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPIsReady(_nativeIndex);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public long PlayerGetLength(object playerObject = null)
|
||||
{
|
||||
public long PlayerGetLength(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetLength(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetLength(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long PlayerGetTime(object playerObject = null)
|
||||
{
|
||||
public long PlayerGetTime(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetTime(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetTime(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void PlayerSetTime(long time, object playerObject = null)
|
||||
{
|
||||
public void PlayerSetTime(long time, object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetTime(_nativeIndex, (int)time);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetTime(_nativeIndex, (int)time);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public float PlayerGetPosition(object playerObject = null)
|
||||
{
|
||||
public float PlayerGetPosition(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetPosition(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetPosition(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void PlayerSetPosition(float pos, object playerObject = null)
|
||||
{
|
||||
public void PlayerSetPosition(float pos, object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetPosition(_nativeIndex, pos);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetPosition(_nativeIndex, pos);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public float PlayerGetRate(object playerObject = null)
|
||||
{
|
||||
public float PlayerGetRate(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetRate(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetRate(_nativeIndex);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public bool PlayerSetRate(float rate, object playerObject = null)
|
||||
{
|
||||
public bool PlayerSetRate(float rate, object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetRate(_nativeIndex, rate);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetRate(_nativeIndex, rate);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int PlayerGetVolume(object playerObject = null)
|
||||
{
|
||||
public int PlayerGetVolume(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetVolume(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetVolume(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int PlayerSetVolume(int volume, object playerObject = null)
|
||||
{
|
||||
public int PlayerSetVolume(int volume, object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetVolume(_nativeIndex, volume);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetVolume(_nativeIndex, volume);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public bool PlayerGetMute(object playerObject = null)
|
||||
{
|
||||
public bool PlayerGetMute(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetMute(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPGetMute(_nativeIndex);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void PlayerSetMute(bool mute, object playerObject = null)
|
||||
{
|
||||
public void PlayerSetMute(bool mute, object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetMute(_nativeIndex, mute);
|
||||
if (_nativeIndex >= 0)
|
||||
UMPSetMute(_nativeIndex, mute);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public int PlayerVideoWidth(object playerObject = null)
|
||||
{
|
||||
public int PlayerVideoWidth(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPVideoWidth(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPVideoWidth(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int PlayerVideoHeight(object playerObject = null)
|
||||
{
|
||||
public int PlayerVideoHeight(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPVideoHeight(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPVideoHeight(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int PlayerVideoFramesCounter(object playerObject = null)
|
||||
{
|
||||
public int PlayerVideoFramesCounter(object playerObject = null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPVideoFrameCount(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
return UMPVideoFrameCount(_nativeIndex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public PlayerState PlayerGetState()
|
||||
{
|
||||
var eventValue = PlayerState.Empty;
|
||||
public PlayerState PlayerGetState()
|
||||
{
|
||||
var eventValue = PlayerState.Empty;
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
if (_nativeIndex >= 0)
|
||||
eventValue = (PlayerState)UMPGetState(_nativeIndex);
|
||||
if (_nativeIndex >= 0)
|
||||
eventValue = (PlayerState)UMPGetState(_nativeIndex);
|
||||
#endif
|
||||
return eventValue;
|
||||
}
|
||||
return eventValue;
|
||||
}
|
||||
|
||||
public object PlayerGetStateValue()
|
||||
{
|
||||
public object PlayerGetStateValue()
|
||||
{
|
||||
#if UNITY_IOS || UNITY_WEBGL
|
||||
object value = UMPGetStateFloatValue(_nativeIndex);
|
||||
object value = UMPGetStateFloatValue(_nativeIndex);
|
||||
|
||||
if ((float)value < 0)
|
||||
{
|
||||
value = UMPGetStateLongValue(_nativeIndex);
|
||||
if ((long)value < 0)
|
||||
value = UMPGetStateStringValue(_nativeIndex);
|
||||
}
|
||||
if ((float)value < 0)
|
||||
{
|
||||
value = UMPGetStateLongValue(_nativeIndex);
|
||||
if ((long)value < 0)
|
||||
value = UMPGetStateStringValue(_nativeIndex);
|
||||
}
|
||||
|
||||
return value;
|
||||
return value;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user