Playig EasyMovieTexture拥有巨大的360°视频

时间:2018-01-15 13:46:09

标签: c# android unity3d video

我使用Unity3D-Asset“EasyMovieTexture”在一个范围内显示360-Videos,并希望将其构建为Android应用程序。

我从本地SD卡流式传输它而不将其保存到应用程序的持久数据路径中(就像它在演示函数中一样)。

问题: 大于500MB的视频让我的应用程序崩溃。是否可以通过添加一些功能来流式传输(本地)更大的视频?或者它是我设备中的“边界”?我将视频分成了较小的部分,但它不是我应用程序的最佳解决方案......

其他一切都很好......

顺便说一下: 正常的Unity Videoplayer对我来说不是一个实用的解决方案,因为它非常生涩。所以我决定使用EasyMovieTexture。

如果有人为我提供信息,那将是非常好的。

设备:

Android 7.0, 三星S6

在下面的代码中,当我尝试“加载”(eq stream)一个大小超过1GB的视频文件时,应用程序崩溃

    // Own Class
    public MediaPlayerCtrl mediaPlayerCtrl;
    private string VIDEO_PLAYLIST_01 = "xyz";

    // delegeate for changing video file in lifetime
    public void onVideoChange(object _video) {

       int number = (int)_video;
       string[] temp = (Application.persistentDataPath.Replace("Android", "")).Split(new string[] { "//" }, System.StringSplitOptions.None);

       // stop latest video     
       mediaPlayerCtrl.Stop();
       mediaPlayerCtrl.m_strFileName = null;
       mediaPlayerCtrl.m_bLoop = false;

       switch (number) {

       case 1:

          if (File.Exists(temp[0] + "/Download/" +  VIDEO_PLAYLIST_01 + ".mp4")) {
             // if file found load the stream of it with easymovietexturectrol
             StartCoroutine(openStream(VIDEO_PLAYLIST_01));
          } else {
             Application.Quit();
          }
       break;

       default: 
          break;
       }
     }

     IEnumerator openStream(string vid) {
        mediaPlayerCtrl.OnVideoFirstFrameReady += firstFrameReady;
        // wait until stream loaded        
        yield return StartCoroutine(mediaPlayerCtrl.StreamVideoFromPath("file://" + temp[0] + "/Download/" + vid + ".mp4"));
     }
// Class of Easy Movie Texture - MoviePlayerCtrl 
// i used the "DownloadStreamingVideoAndLoad2" before and then it crashes cause
// this class load a fully bytefile of the video in the persistent path. my class 
//only loads things by using the www-class 

public IEnumerator StreamVideoFromPath(string strURL) {

    strURL = strURL.Trim();

    WWW www = new WWW(strURL);
    yield return www;

    if (string.IsNullOrEmpty(www.error)) {
       Load("file://" + strURL);
       Debug.Log(strURL);
    } else {                
       Debug.Log(www.error);
       Application.Quit();
    }

    www.Dispose();
    www = null;
    Resources.UnloadUnusedAssets();
}

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法:不要使用WWW-Class从SD卡中传输mp4-file。仅在Coroutine中使用Load(“file://”+ strURL)。它在我的3D-Sphere-Texture上传输了一个非常智能的3GB视频文件。

public IEnumerator StreamVideoFromPathWithoutLoadingItIntoMemory(string strURL) {

    strURL = strURL.Trim();
    Load("file://" + strURL);

    Debug.Log(strURL);
    Resources.UnloadUnusedAssets();
}