Main Site Documentation

Music module from SD out of memory


#1

Whats wrong with this code, as it fails with out of memory…??


using System;
using System.IO;
using System.Threading;
using Microsoft.SPOT;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHIElectronics.Gadgeteer;

namespace MusicTest1
{
    public partial class Program
    {
            
        void ProgramStarted()
        {
            Debug.Print("Program started");
            music.MusicFinished +=music_MusicFinished;
            sdCard.Mounted += sdCard_Mounted;
            music.SetVolume(200, 200);
            
        }

        private void music_MusicFinished(Music sender, EventArgs e)
        {
            Debug.Print("Finished playing this song");
        }

        void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
        {
            Debug.Print("Now playing..");
            music.Play(@ "\SD\lyd.wma");
            //wait until audio is over
            while (music.IsBusy)
                Thread.Sleep(10);
        }
    }
}


#2

[quote=“andre.m”]i assume

music.Play(@ "\SD\lyd.wma");

loads the complete file into your memory and your file is bigger?[/quote]

You were right, but it still does not play the files. The old version with streams is great, but I would like to try this with the file path. But silence!

I have tried many files now, including this one which was too big
:wink: