Example #1
0
    // Checks whether the audio and video file formats of the song are supported.
    // Returns true iff the audio file of the SongMeta exists and is supported.
    private bool CheckSupportedMediaFormats(SongMeta songMeta)
    {
        // Check video format.
        // Video is optional.
        if (!songMeta.Video.IsNullOrEmpty())
        {
            if (!ApplicationUtils.IsSupportedVideoFormat(Path.GetExtension(songMeta.Video)))
            {
                Debug.LogWarning("Unsupported video format: " + songMeta.Video);
                songMeta.Video = "";
            }
            else if (!File.Exists(SongMetaUtils.GetAbsoluteSongVideoPath(songMeta)))
            {
                Debug.LogWarning("Video file does not exist: " + SongMetaUtils.GetAbsoluteSongVideoPath(songMeta));
                songMeta.Video = "";
            }
        }

        // Check audio format.
        // Audio is mandatory. Without working audio file, the song cannot be played.
        if (!ApplicationUtils.IsSupportedAudioFormat(Path.GetExtension(songMeta.Mp3)))
        {
            Debug.LogWarning("Unsupported audio format: " + songMeta.Mp3);
            return(false);
        }
        else if (!File.Exists(SongMetaUtils.GetAbsoluteSongFilePath(songMeta)))
        {
            Debug.LogWarning("Audio file does not exist: " + SongMetaUtils.GetAbsoluteSongFilePath(songMeta));
            return(false);
        }

        return(true);
    }