0
0

Hello again,

I’m trying to write a MP3-Player in C# using FMODex.
Everthing works fine by now. My Problem noiw is, that use the openStream Routine to open my files quickly. Now i’m trying to do a Playlist, but I can only play new Files, Files which were loaded before (played before) I can’t load again.

Seems like the Stream remains in the Buffer. I don’t know how to flush the buffer or stop the whole Playback and load it again.

I tried to set the Position to the end, because I read something like this in the Documentation, but it won’t work. If I use the openFile Routine it works quiet fine – but need lots of time to load. Skipping PlaylistEntries will take much to long in this case.

Any Idea how to solve my (little) problem, I don’t want to use a other Soundengine only because of this Prob.

Marcus

  • You must to post comments
0
0

Hello man!! =)

I am write player under win32 and unix
delphi and c++

with using fmod ex but i don’t have errors

good luck man!! =)

  • You must to post comments
0
0

and How could i Fix this?

I guess I should post some (C#) code:

[size=75:1h3nwpvv]
[code:1h3nwpvv]

using System;
using System.Data;
using System.Runtime.InteropServices;

namespace MP3_FMOD
{
/// <summary>
/// Zusammenfassung für FMOD_MP3.
/// </summary>
public class FMOD_MP3
{

    private FMOD.System     system  = null;
    private FMOD.Sound      sound   = null;
    private FMOD.Channel    channel = null;

    private uint            ms      = 0;
    private uint            lenms   = 0;

    private bool            Playing = false;
    private bool            Stopped = false;
    private bool            Paused  = false;
    private bool            Loaded  = false;

    private string          file = null;

    private int             channelsplaying = 0;
    private uint            version = 0;

    public FMOD_MP3()
    {
        FMOD.Factory.System_Create(ref system);
        system.getVersion(ref version);

        if (version &lt; FMOD.VERSION.number)
        {
            System.Windows.Forms.MessageBox.Show(&quot;Error!  You are using an old version of FMOD &quot; + version.ToString(&quot;X&quot;) + &quot;.  This program requires &quot; + FMOD.VERSION.number.ToString(&quot;X&quot;) + &quot;.&quot;);
        }

    }

    public void Init()
    {
        system.init(1, FMOD.INITFLAG.NORMAL, (IntPtr)null);
    }

    public void Init(int maxchannels)
    {
        system.init(maxchannels, FMOD.INITFLAG.NORMAL, (IntPtr)null);
    }


    public void LoadStream(string filename)
    {
        Stop();

        if (system != null)
        {
            system.update();
        }
        FMOD.RESULT result = system.createStream(filename, FMOD.MODE.ACCURATETIME, ref sound);  

        if (result == FMOD.RESULT.OK)
        {
            Loaded = true;
            sound.setMode(FMOD.MODE.LOOP_OFF);
            sound.setMode(FMOD.MODE.IGNORETAGS);
            sound.setMode(FMOD.MODE.SOFTWARE);
            file = filename;
        }
    }

    public void PlayOrPause()
    {
        if (Playing)
        {
            FMOD.RESULT result;
            bool paused = false;

            if (channel != null)
            {
                result = channel.getPaused(ref paused);
                result = channel.setPaused(!paused);
            }
        }

        else if (Loaded)
        {
            FMOD.RESULT result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);

            if (result == FMOD.RESULT.OK)
            {
                Playing = true;
            }
        }
    }


    public void Stop()
    {
        FMOD.RESULT result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, true, ref channel);

        if (result == FMOD.RESULT.OK)
        {
            Playing = false;
        }
    }


    public void setPos(int pos)
    {
        channel.setPosition((uint)pos,FMOD.TIMEUNIT.MS);
    }

    public int getPos()
    {
        uint pos = 0;
        channel.getPosition(ref pos,FMOD.TIMEUNIT.MS);
        return (int)pos;
    }

    public int getLength()
    {
        uint length = 0;
        sound.getLength(ref length,FMOD.TIMEUNIT.MS);
        return (int)length;
    }
}

}
[/code:1h3nwpvv][/size:1h3nwpvv]

thanks so long..
Marcus

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.