Example #1
0
    /*
     *  ----------------------------
     *  PUBLIC IMPLEMENTATION:
     *  ----------------------------
     */

    public void AutomatedDownloadAndPlay(string downloadLocation, string filename, string extension, DownloadAndPlayEvents events = null)
    {
        //debug.Log("[DownloadAndPlay] Automated DownloadAndPlay: " + downloadLocation + filename);

        if (events == null)
        {
            events = new DownloadAndPlayEvents();
        }

        LoadMovieAndPlay(downloadLocation, filename, extension, events, false);
    }
Example #2
0
    /*
     *  ----------------------------
     *  LOCAL IMPLEMENTATION:
     *  ----------------------------
     */

    void LoadMovieAndPlay(string downloadLocation, string filename, string extension, DownloadAndPlayEvents events, bool isRecursive = false)
    {
        if (!deviceStorage.Exist(filename + extension))
        {
            if (!isRecursive)
            {
                DownloadMovie
                (
                    downloadLocation,
                    filename,
                    (WWW www) =>
                {
                    if (events.DownloadComplete != null)
                    {
                        events.DownloadComplete(www);
                    }

                    //debug.Log("[DownloadAndPlay] Download Complete");

                    //if (!string.IsNullOrEmpty(www.error))
                    //    debug.Log("[DownloadAndPlay] Download ERROR: " + www.error);

                    WriteToFile(filename + extension, www.bytes);
                    LoadMovieAndPlay(downloadLocation, filename, extension, events, true);
                },
                    (float p) =>
                {
                    // debug.Log("[DownloadAndPlay] Progress: " + p);
                    if (events.DownLoadProgress != null)
                    {
                        events.DownLoadProgress(p);
                    }
                }


                );
            }
            else
            {
                if (events.WriteFailed != null)
                {
                    events.WriteFailed();
                }
                //debug.Log("[DownloadAndPlay] WriteFailed");
            }
        }
        else
        {
            PlayMovie(filename + extension, () =>
            {
                //debug.Log("[DownloadAndPlay] Movie Finished");
                if (events.MovieFinished != null)
                {
                    events.MovieFinished();
                }
            });
        }
    }