Load() public method

public Load ( string strFileName ) : void
strFileName string
return void
Beispiel #1
0
    // Functions ///////////////////////////////////////////////////////////////////////////////////////
    IEnumerator LoadVideo(zVideo loadTarget)
    {
        MediaPlayerCtrl vc = loadTarget.videoPlayerCtrl; // mediaPlayerCtrl we will be messing with

        vc.Load(loadTarget.videoUrl);                    // Load video

        while (vc.GetCurrentState() != MediaPlayerCtrl.MEDIAPLAYER_STATE.READY)
        {
            yield return(false);  // Wait until video has been loaded
        }
        vc.Play();

        Debug.Log("Done");

        yield return(true);
    }
Beispiel #2
0
        /// <summary>
        /// 对按钮添加相应事件
        /// </summary>
        public void OnEnable()
        {
            description.text = item.description;
            title.text       = item.itemname;

            if (mediaplayer != null)
            {
                mediaplayer.Load(item.tutourl);
                mediaplayer.Pause();
            }

            //设置下载按钮文字,若是已缓存至本地则为false,反之
            if (!SKassetbundlehelper.instance.Checkcache(item.Getitemurl(), item.version))
            {
                downloadtext.text           = "<color=#3266BAFF>点击下载</color>";
                downloadprogress.fillAmount = 0;
            }
            else
            {
                downloadtext.text           = "<color=white>进入体验</color>";
                downloadprogress.fillAmount = 1;
            }

            if (item != null)
            {
                Browser.Getinstance().GetMarkless(item.tutorthumbnail, Setuptutorthumbnail, null, videopayer);
            }
#if VERSION2_0
            Sqlitehelper     helper = new Sqlitehelper("data source=skbrowser.db");
            SqliteDataReader sdr    = helper.Readfromid("favorite_test", "id", item.id.ToString());
            if (sdr.HasRows)
            {
                favorite.GetComponent <Image>().sprite = Resources.Load <Sprite>("Ui/btn_like_sel");
            }
            else
            {
                favorite.GetComponent <Image>().sprite = Resources.Load <Sprite>("Ui/btn_like_nor");
            }
            helper.CloseSqlConnection();
#endif
        }
Beispiel #3
0
    static public bool LoadVideoCache(string fileName)
    {
        GameObject tmpObj = new GameObject();

        MonoBehaviour.DontDestroyOnLoad(tmpObj);
        MediaPlayerCtrl tmpCtrl = tmpObj.AddComponent <MediaPlayerCtrl>();

        tmpCtrl.Load(fileName);
        if (tmpCtrl != null)
        {
            tmpCtrl.SetVolume(0f);
            _videoCache[fileName] = tmpObj as GameObject;
            return(true);
        }
        else
        {
            UnityEngine.Object.Destroy(tmpObj);
            Debug.Log("File not found : " + fileName);
            return(false);
        }
    }
    public EasyMovieTexture.PlayResult PlayFullScreenMovie(string url, EasyMovieTexture.ControlMode controlMode, EasyMovieTexture.OnFinished callback)
    {
        GameObject      gameObject = AssetManager.Load <GameObject>("UI/FullScreenMovie");
        MediaPlayerCtrl ctrl       = (MediaPlayerCtrl)null;

        this.onFinished = callback;
        if (Object.op_Inequality((Object)gameObject, (Object)null))
        {
            ctrl = (MediaPlayerCtrl)((GameObject)Object.Instantiate <GameObject>((M0)gameObject)).GetComponent <MediaPlayerCtrl>();
        }
        if (Object.op_Inequality((Object)ctrl, (Object)null))
        {
            ctrl.OnReady += new MediaPlayerCtrl.VideoReady(this.OnReady);
            ctrl.OnVideoFirstFrameReady += new MediaPlayerCtrl.VideoFirstFrameReady(this.OnFirstFrameReady);
            ctrl.OnVideoError           += new MediaPlayerCtrl.VideoError(this.OnError);
            ctrl.OnEnd    += new MediaPlayerCtrl.VideoEnd(this.OnEnd);
            ctrl.OnResize += new MediaPlayerCtrl.VideoResize(this.OnResize);
        }
        ctrl.Load(url);
        return(new EasyMovieTexture.PlayResult(ctrl));
    }
Beispiel #5
0
    void onAdminVideo2Ended()
    {
        if (adminVideo2.m_strFileName == "putitback.mp4")
        {
            mainUI.SetActive(true);
            enableNextBtn();
        }
        else
        {
            adminVideo2.Stop();
            adminVideo2.UnLoad();
            //adminVideo2.gameObject.SetActive (false);
            adminVideo2.OnEnd -= onAdminVideo2Ended;

            mainUI.SetActive(true);

            adminVideo2.Load("putitback.mp4");

            pauseUI.SetActive(false);

            photoController.GetImageFromCamera();
        }
    }
Beispiel #6
0
    IEnumerator PlayVideoFake(VideoInfo info, float delay)
    {
        UpdateScreen();
        ShowLoadAnimation();

        yield return(new WaitForSeconds(1f));

//		videoPlayer.DownloadStreamingVideoAndLoad( info.playUrl );
//		videoPlayer.m_strFileName = info.playUrl;
        videoPlayer.Load(info.playUrl);

        yield return(new WaitForSeconds(1f));

        videoPlayer.Play();

        while (videoPlayer.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY)
        {
            yield return(null);
        }

        HideLoadAnimation();
        OnPlayVideo();
    }
Beispiel #7
0
    void OnEnable()
    {
        if (Main.Main3DCamera != null)
        {
            Main.Main3DCamera.enabled = false;
        }

        if (_VideoManagerObj != null)
        {
            this.Resize();

            _MediaCtrl = _VideoManagerObj.GetComponent <MediaPlayerCtrl>();
            if (_MediaCtrl == null)
            {
                _MediaCtrl = _VideoManagerObj.AddComponent <MediaPlayerCtrl>();
            }
            _MediaCtrl.m_strFileName = _VideoName;
            _MediaCtrl.m_bFullScreen = true;    //全屏
            _MediaCtrl.m_bLoop       = _IsLoop; //是否循环播放
            _MediaCtrl.m_bAutoPlay   = true;    //自动播放
            _MediaCtrl.OnReady       = OnVideoReady;
            _MediaCtrl.OnEnd         = OnVideoEnd;
            if (_IsPauseOnFirstFrame)
            {
                _MediaCtrl.OnVideoFirstFrameReady = OnVideoFirstFrameReady;
            }
            else
            {
                _MediaCtrl.OnVideoFirstFrameReady = null;
            }
            _MediaCtrl.DeleteVideoTexture();

            _MediaCtrl.Load(_MediaCtrl.m_strFileName);

            _VideoManagerObj.SetActive(true);
        }
    }
Beispiel #8
0
//Load some file to the MediaPlayer Controller for the GameObject and play
    private void Awake()
    {
        Debug.Log("alive");
        mCtrl1.Load("IXDAParody.mp4");
        mCtrl1.Play();
    }
Beispiel #9
0
 public override void OnTrackingFound()
 {//发现AR目标时,载入视频
     mediaPlayerCtrl.Load(videoStr);
 }
 public void PassURL(string Id)                                                                                      //Pass the URL to MediaPlayerCtrl
 {
     scrMedia.Load(YoutubeVideo.Instance.RequestVideo(Id, DefaultResolution).ToString());
 }
Beispiel #11
0
 public void EndingMoviePlay()
 {
     ending_movie.SetActive(true);
     ending_movie_control.Load("ending.mp4");
 }
 void InvokeLoad()
 {
     MojingSDK.Unity_ResetTracker();
     mediaCtrl.Load("file:///sdcard/DCCPlayer/" + mp4Name);
     isPlaying = true;
 }
Beispiel #13
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(50, 50, 100, 100), "Load"))
        {
            scrMedia.Load("EasyMovieTexture.mp4");
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(50, 200, 100, 100), "Play"))
        {
            scrMedia.Play();
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(50, 350, 100, 100), "stop"))
        {
            scrMedia.Stop();
        }

        if (GUI.Button(new Rect(50, 500, 100, 100), "pause"))
        {
            scrMedia.Pause();
        }

        if (GUI.Button(new Rect(50, 650, 100, 100), "Unload"))
        {
            scrMedia.UnLoad();
        }

        if (GUI.Button(new Rect(50, 800, 100, 100), " " + m_bFinish))
        {
        }

        if (GUI.Button(new Rect(200, 50, 100, 100), "SeekTo"))
        {
            scrMedia.SeekTo(10000);
        }


        if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            if (GUI.Button(new Rect(200, 200, 100, 100), scrMedia.GetSeekPosition().ToString()))
            {
                scrMedia.SetSpeed(2.0f);
            }

            if (GUI.Button(new Rect(200, 350, 100, 100), scrMedia.GetDuration().ToString()))
            {
                scrMedia.SetSpeed(1.0f);
            }

            if (GUI.Button(new Rect(200, 450, 100, 100), scrMedia.GetVideoWidth().ToString()))
            {
            }

            if (GUI.Button(new Rect(200, 550, 100, 100), scrMedia.GetVideoHeight().ToString()))
            {
            }
        }

        if (GUI.Button(new Rect(200, 650, 100, 100), scrMedia.GetCurrentSeekPercent().ToString()))
        {
        }
    }
    void OnGUI()
    {
        if (GUI.Button(new Rect(7 * (Screen.width / spaceBtnW), (Screen.height / spaceBtnH), btnWidth, btnHeight), "Reset"))
        {
            currentVideoIndex = 0;
            scrMedia.Load("" + strVideoName[currentVideoIndex]);
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(7 * (Screen.width / spaceBtnW), 4 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Next"))
        {
            if (currentVideoIndex != strVideoName.Length - 1)
            {
                currentVideoIndex += 1;
                scrMedia.Load("" + strVideoName[currentVideoIndex]);
                m_bFinish = false;
            }
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), (Screen.height / spaceBtnH), btnWidth, btnHeight), "Load"))
        {
            scrMedia.Load("" + strVideoName[currentVideoIndex]);
            m_bFinish = false;
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 4 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Play"))
        {
            scrMedia.Play();
            m_bFinish = false;
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 7 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Stop"))
        {
            scrMedia.Stop();
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 10 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Pause"))
        {
            scrMedia.Pause();
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 13 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Unload"))
        {
            scrMedia.UnLoad();
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 16 * (Screen.height / spaceBtnH), btnWidth, btnHeight), " " + m_bFinish))
        {
        }

        if (GUI.Button(new Rect(4 * (Screen.width / spaceBtnW), (Screen.height / spaceBtnH), btnWidth, btnHeight), "SeekTo"))
        {
            scrMedia.SeekTo(10000);
        }


        if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            if (GUI.Button(new Rect(4 * (Screen.width / spaceBtnW), 4 * (Screen.height / spaceBtnH), btnWidth, btnHeight), scrMedia.GetSeekPosition().ToString()))
            {
            }

            if (GUI.Button(new Rect(4 * (Screen.width / spaceBtnW), 7 * (Screen.height / spaceBtnH), btnWidth, btnHeight), scrMedia.GetDuration().ToString()))
            {
            }
        }
    }
Beispiel #15
0
        private IEnumerator Initialize()
        {
            movieRenderer = targetSurface.GetComponent <Renderer>();
            if (movieRenderer == null ||
                movieRenderer.material == null ||
                movieRenderer.material.mainTexture == null)
            {
                UpdateState(StateType.Error);
                throw new Exception(TAG + " No surface for media found.");
            }
#if USE_EASY_MOVIE_TEXTURE
            // Prevent Awake called before properties loaded.
            gameObject.SetActive(false);
            // Load EasyMovieTexture properties at runtime.
            easyMovieTexture             = gameObject.AddComponent <MediaPlayerCtrl>() as MediaPlayerCtrl;
            easyMovieTexture.m_bAutoPlay = false;
            easyMovieTexture.m_bLoop     = loop;
            //easyMovieTexture.m_strFileName = videoFile;
            easyMovieTexture.m_TargetMaterial    = new GameObject[1];
            easyMovieTexture.m_TargetMaterial[0] = targetSurface;
            easyMovieTexture.m_bSupportRockchip  = true;
            easyMovieTexture.m_shaderYUV         = Shader.Find("Unlit/Unlit_YUV");
            gameObject.SetActive(true);

            easyMovieTexture.OnReady += OnPrepareComplete;
            easyMovieTexture.OnEnd   += OnVideoPlayComplete;

            easyMovieTexture.Load(videoFile);
            // Following steps will be handled by EasyMovieTexture.
            yield break;
#elif USE_UNITY_VIDEO_PLAYER
            videoPlayer                        = gameObject.AddComponent <UnityEngine.Video.VideoPlayer>();
            videoPlayer.renderMode             = UnityEngine.Video.VideoRenderMode.MaterialOverride;
            videoPlayer.targetMaterialRenderer = targetSurface.GetComponent <MeshRenderer>();

            audioSource = gameObject.AddComponent <AudioSource>();
            videoPlayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource;
            videoPlayer.SetTargetAudioSource(0, audioSource);

            videoPlayer.skipOnDrop = true;
            videoPlayer.isLooping  = loop;

            videoPlayer.prepareCompleted += (e) => { OnPrepareComplete(); };
            videoPlayer.loopPointReached += (e) => { OnVideoPlayComplete(); };

            yield return(null);

            string mediaUrl = "file://" + Application.streamingAssetsPath + "/" + videoFile;
#if UNITY_ANDROID && !UNITY_EDITOR
            //mediaUrl = "jar:" + mediaUrl;
            string assetsPath = Application.streamingAssetsPath + "/" + videoFile;
            string dataPath   = Application.persistentDataPath + "/" + videoFile;
            if (!File.Exists(dataPath))
            {
                WWW wwwReader = new WWW(assetsPath);
                yield return(wwwReader);

                if (wwwReader.error != null)
                {
                    Debug.LogError(TAG + " wwwReader error: " + wwwReader.error);
                }

                System.IO.File.WriteAllBytes(dataPath, wwwReader.bytes);
            }
            mediaUrl = dataPath;
#endif
            videoPlayer.url = mediaUrl;
#elif USE_ANDROID_MEDIA_PLAYER
            Media_Surface_Init();
            // TODO: Fix ArgumentException: nativeTex can not be null in Unity 2017.
            nativeTexture = Texture2D.CreateExternalTexture(
                textureWidth,
                textureHeight,
                TextureFormat.RGBA32,
                true,
                false,
                IntPtr.Zero
                );
            IssuePluginEvent(MediaSurfaceEventType.Initialize);

            string assetsPath = Application.streamingAssetsPath + "/" + videoFile;
            string dataPath   = Application.persistentDataPath + "/" + videoFile;
            if (!File.Exists(dataPath))
            {
                WWW wwwReader = new WWW(assetsPath);
                yield return(wwwReader);

                if (wwwReader.error != null)
                {
                    Debug.LogError(TAG + " wwwReader error: " + wwwReader.error);
                }

                System.IO.File.WriteAllBytes(dataPath, wwwReader.bytes);
            }

            // Delay 1 frame to allow MediaSurfaceInit from the render thread.
            yield return(null);

            mediaPlayer = GetMediaPlayerOnTextureID(textureWidth, textureHeight);

            try
            {
                mediaPlayer.Call("setDataSource", dataPath);
                mediaPlayer.Call("setLooping", loop);
            }
            catch (Exception e)
            {
                Debug.LogError(TAG + " Failed to load video for mediaPlayer: " + e.Message);
            }
#elif USE_VIVE_MEDIA_DECODER
            targetSurface.GetComponent <Renderer>().material = convertMaterial;

            mediaDecoder = targetSurface.AddComponent <HTC.UnityPlugin.Multimedia.MediaDecoder>()
                           as HTC.UnityPlugin.Multimedia.MediaDecoder;

            if (stereoSurface != null && stereoSurface2 != null)
            {
                HTC.UnityPlugin.Multimedia.StereoHandler.StereoType stereoType
                    = HTC.UnityPlugin.Multimedia.StereoHandler.StereoType.SIDE_BY_SIDE;
                if (stereoSurface.name == "UpSurface")
                {
                    stereoType = HTC.UnityPlugin.Multimedia.StereoHandler.StereoType.TOP_DOWN;
                }
                HTC.UnityPlugin.Multimedia.StereoHandler.SetStereoPair(
                    stereoSurface,
                    stereoSurface2,
                    movieRenderer.material,
                    stereoType,
                    true);
            }
            mediaDecoder.onInitComplete = new UnityEvent();
            mediaDecoder.onInitComplete.AddListener(OnPrepareComplete);
            mediaDecoder.onVideoEnd = new UnityEvent();
            mediaDecoder.onVideoEnd.AddListener(OnVideoPlayComplete);

            mediaDecoder.mediaPath = Application.streamingAssetsPath + "/" + videoFile;
            yield return(null);
#else
            audioSource = gameObject.AddComponent <AudioSource>();

            if (!Path.GetExtension(videoFile).Equals(".ogv") &&
                !Path.GetExtension(videoFile).Equals(".ogg"))
            {
                if (File.Exists(
                        Application.streamingAssetsPath + "/" +
                        Path.GetDirectoryName(videoFile) + "/" +
                        Path.GetFileNameWithoutExtension(videoFile) + ".ogv"
                        ))
                {
                    videoFile = Path.GetDirectoryName(videoFile) + "/" +
                                Path.GetFileNameWithoutExtension(videoFile) + ".ogv";
                }
                else if (File.Exists(
                             Application.streamingAssetsPath + "/" +
                             Path.GetDirectoryName(videoFile) + "/" +
                             Path.GetFileNameWithoutExtension(videoFile) + ".ogg"
                             ))
                {
                    videoFile = Path.GetDirectoryName(videoFile) + "/" +
                                Path.GetFileNameWithoutExtension(videoFile) + ".ogg";
                }
                else
                {
                    UpdateState(StateType.Error);
                    throw new Exception("Only support ogv/ogg video format on Standalone platform.");
                }
            }
            WWW wwwReader = new WWW("file:///" + Application.streamingAssetsPath + "/" + videoFile);
            yield return(wwwReader);

            if (wwwReader.error != null)
            {
                UpdateState(StateType.Error);
                Debug.LogError(TAG + " wwwReader error: " + wwwReader.error);
            }
            // Here is an issue in Unity Editor, please ignore the error if you
            // see the error below in console:
            // LoadMoveData got NULL!
            // Error: Cannot create FMOD::Sound instance for resource (null), (An invalid parameter was passed to this function. )
            //
            // Issue:
            // https://issuetracker.unity3d.com/issues/calling-www-dot-movie-fails-to-load-and-prints-error-loadmovedata-got-null
            // https://issuetracker.unity3d.com/issues/movietexture-fmod-error-when-trying-to-play-video-using-www-class
            movieTexture = wwwReader.movie;
            movieRenderer.material.mainTexture = movieTexture;
            audioSource.clip  = movieTexture.audioClip;
            movieTexture.loop = loop;
#endif
            UpdateState(StateType.Initialized);
            StartCoroutine(Prepare());
        }
        //--------------------------------------------------
        // 实现公有方法
        //--------------------------------------------------

        public override void Load(string path)
        {
            player.Load(path);
        }
Beispiel #17
0
 public void Load(string filename)
 {
     videoPlayer.Load(filename);
 }
Beispiel #18
0
 public void continueVideo()
 {
     scrMedia.Stop();
     scrMedia.Load("ContinueVideo.mp4");
     scrMedia.Play();
 }
Beispiel #19
0
 /// <summary>
 /// Load video
 /// </summary>
 /// <param name="path">video path</param>
 void LoadVideo(string path)
 {
     easyMovieTexture.Load(path);
 }
Beispiel #20
0
 public void LoadButtonPressed()
 {
     controls.Load("EasyMovieTexture.mp4");
 }
Beispiel #21
0
 public void FacebookMoviePlay()
 {
     fb_movie.SetActive(true);
     fb_movie_control.Load("movie_fb.mp4");
 }