Ejemplo n.º 1
0
    public void SetSong(int id, string path)
    {
        string extension = IO.Path.GetExtension(path);
        bool   isAudio   = BeatmapLoader.SupportedAudioFormats.Contains <string>(extension);
        bool   isBeatmap = (extension == BeatmapLoader.BeatmapFileFormat);

        if (isAudio || isBeatmap)
        {
            string audioFile;
            string sourceFile;
            if (isAudio)
            {
                BeatmapContainer = BeatmapLoader.CreateBeatmapFromAudio(path);
                audioFile        = sourceFile = path;
            }
            else
            {
                BeatmapContainer = BeatmapLoader.LoadBeatmapFile(path);
                audioFile        = IO.Path.Combine(BeatmapContainer.directory, BeatmapContainer.bm.AudioFile);
                sourceFile       = BeatmapContainer.sourceFile;
            }

            this.id          = id;
            Thumbnail.sprite = null;
            TagLib.File tfile = TagLib.File.Create(audioFile);
            SongName            = tfile.Tag.Title != null ? tfile.Tag.Title : IO.Path.GetFileNameWithoutExtension(sourceFile);
            ArtistName          = tfile.Tag.FirstPerformer;
            DifficultyText.text = "N/A";
            //Difficulty.text = Math.Round(BeatmapContainer.bm.Metadata.Difficulty, 1).ToString();
            //Difficulty.color = Color.Lerp(Color.green, Color.red, BeatmapContainer.bm.Metadata.Difficulty / 5f);
            DurationText.text = tfile.Properties.Duration.ToString(@"mm\:ss");
        }
    }
Ejemplo n.º 2
0
    private void LoadBeatmap()
    {
        string path = BeatmapLoader.SelectBeatmapFile();

        if (path != null)
        {
            BeatmapContainer bmc = BeatmapLoader.LoadBeatmapFile(path);
            AudioClipData    cd  = BeatmapLoader.LoadBeatmapAudio(bmc);
            audioPlayer.clip = BeatmapLoader.CreateAudioClipFromData(cd);
            bm = bmc.bm;
        }
    }