Open dw8869 opened 1 week ago
It worked fine with AVProVideo v2.9.x. Here is my test code on DemoScene.
private IEnumerator Start()
{
// wait for create player.Cache.
while (player.Cache is null)
{
yield return null;
}
player.Cache.AddMediaToCache(url);
player.OpenMedia(new MediaPath(url, MediaPathType.AbsolutePathOrURL), true);
}
public void Update()
{
if (player != null && player.Cache != null)
{
float progress = 0f;
var status = player.Cache.GetCachedMediaStatus(url, ref progress);
Debug.Log($"GetCachedMediaStatus: {status} / {progress}");
}
}
Thanks for reporting this.
We will have this fixed in the next release (v3.0.5).
If you wish to apply a fix to your current working copy of the asset, then you can simply modify some script code...
NOTE: This script change will break iOS caching. Naturally they will both be in a working state for the next build we release.
#if !UNITY_EDITOR && ( UNITY_IOS || UNITY_ANDROID )
// Media Caching
public sealed partial class PlatformMediaPlayer
{
public override bool IsMediaCachingSupported()
{
return true;
}
public override void AddMediaToCache(string url, string headers, MediaCachingOptions options)
{
Native.MediaCachingOptions nativeOptions = new Native.MediaCachingOptions();
GCHandle artworkHandle = new GCHandle();
if (options != null)
{
nativeOptions.minimumRequiredBitRate = options.minimumRequiredBitRate;
nativeOptions.minimumRequiredResolution_width = options.minimumRequiredResolution.x;
nativeOptions.minimumRequiredResolution_height = options.minimumRequiredResolution.y;
nativeOptions.title = options.title;
if (options.artwork != null && options.artwork.Length > 0)
{
artworkHandle = GCHandle.Alloc(options.artwork, GCHandleType.Pinned);
nativeOptions.artwork = artworkHandle.AddrOfPinnedObject();
nativeOptions.artworkLength = options.artwork.Length;
}
}
Native.AVPPluginCacheMediaForURL(_player, url, headers, nativeOptions);
if (artworkHandle.IsAllocated)
{
artworkHandle.Free();
}
}
public override void CancelDownloadOfMediaToCache(string url)
{
Native.AVPPluginCancelDownloadOfMediaForURL(_player, url);
}
public override void RemoveMediaFromCache(string url)
{
Native.AVPPluginRemoveCachedMediaForURL(_player, url);
}
public override CachedMediaStatus GetCachedMediaStatus(string url, ref float progress)
{
return (CachedMediaStatus)Native.AVPPluginGetCachedMediaStatusForURL(_player, url, ref progress);
}
}
#endif
[DllImport(PluginName)]
public static extern void AVPPluginCacheMediaForURL(IntPtr player, string url, string headers, MediaCachingOptions options);
[DllImport(PluginName)]
public static extern void AVPPluginCancelDownloadOfMediaForURL(IntPtr player, string url);
[DllImport(PluginName)]
public static extern void AVPPluginRemoveCachedMediaForURL(IntPtr player, string url);
[DllImport(PluginName)]
public static extern int AVPPluginGetCachedMediaStatusForURL(IntPtr player, string url, ref float progress);
Wow, thank you so much. I'll test it.
@Ste-RH
I tested your code, caching is works fine.
But, does not received FirstFrameReady
.
AVPro Video version 3.0.5 has been released. Please let us know if it has not fixed your issue.
Caching not wokring on Android.
AddMediaToCache
GetCachedMediaStatus