Author Topic: played for checklistbox  (Read 5777 times)

lab82

  • Guest
played for checklistbox
« on: 12 Oct '07 - 15:01 »
Hello,

You know how to do the play by taking the file from a checklistbox?

Thanks.
Sincerely,



Code: [Select]
private void buttonPlay_Click(object sender, System.EventArgs e)
{
_updateTimer.Stop();
Bass.BASS_StreamFree(_stream);
if (_fileName != String.Empty)
{
// create the stream
_stream = Bass.BASS_StreamCreateFile(_fileName, 0, 0, BASSStream.BASS_SAMPLE_FLOAT | BASSStream.BASS_STREAM_PRESCAN);
if (_stream != 0)
{
// used in RMS
_30mslength = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, 0.03f); // 30ms window
// latency from milliseconds to bytes
_deviceLatencyBytes = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, _deviceLatencyMS/1000f);

// set a DSP user callback method
//_myDSPAddr = new DSPPROC(MyDSPGain);
//Bass.BASS_ChannelSetDSP(_stream, _myDSPAddr, 0, 2);
// if you want to use the above two line instead (uncomment the above and comment below)
_myDSPAddr = new DSPPROC(MyDSPGainUnsafe);
Bass.BASS_ChannelSetDSP(_stream, _myDSPAddr, 0, 2);

if (WF != null && WF.IsRendered)
{
// make sure playback and wave form are in sync, since
// we rended with 16-bit but play here with 32-bit
WF.SyncPlayback(_stream);

long cuein  = WF.GetMarker( "CUE" );
long cueout = WF.GetMarker( "END" );

int cueinFrame  = WF.Position2Frames(cuein);
int cueoutFrame = WF.Position2Frames(cueout);
Console.WriteLine( "CueIn at {0}sec.; CueOut at {1}sec.", WF.Frame2Seconds(cueinFrame), WF.Frame2Seconds(cueoutFrame) );

if (cuein >= 0)
{
Bass.BASS_ChannelSetPosition(_stream, cuein);
}
if (cueout >= 0)
{
Bass.BASS_ChannelRemoveSync(_stream, _syncer);
_syncer = Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_POS, cueout, _sync, 0);
}
}
}

if (_stream != 0 && Bass.BASS_ChannelPlay(_stream, false) )
{

_updateTimer.Start();

// get some channel info
BASS_CHANNELINFO info = new BASS_CHANNELINFO();
Bass.BASS_ChannelGetInfo(_stream, info);
// display the tags...
                    /*
TAG_INFO tagInfo = new TAG_INFO(_fileName);
if ( BassTags.BASS_TAG_GetFromFile( _stream, tagInfo) )
{
// and display what we get
this.textBoxAlbum.Text = tagInfo.album;
this.textBoxArtist.Text = tagInfo.artist;
this.textBoxTitle.Text = tagInfo.title;
this.textBoxGenre.Text = tagInfo.genre;
this.textBoxYear.Text = tagInfo.year;
this.textBoxTrack.Text = tagInfo.track;
this.textBoxPicDescr.Text = tagInfo.PictureGetDescription(0);
if (this.textBoxPicDescr.Text == String.Empty)
this.textBoxPicDescr.Text = tagInfo.PictureGetType(0);
}
                     */
this.buttonStop.Enabled = true;
this.buttonPlay.Enabled = false;
}
else
{
int error = Bass.BASS_ErrorGetCode();
Console.WriteLine( Enum.GetName(typeof(BASSErrorCode), error) );
}
}
}
« Last Edit: 12 Oct '07 - 15:16 by lab82 »

lab82

  • Guest
Re: played for checklistbox
« Reply #1 on: 12 Oct '07 - 15:55 »
up..
None?

Thanks..


radio42

  • Posts: 4576
Re: played for checklistbox
« Reply #2 on: 12 Oct '07 - 16:04 »
What is your exact problem?
Is the playback not working?

lab82

  • Guest
Re: played for checklistbox
« Reply #3 on: 12 Oct '07 - 16:53 »
Hello,
My problem, and I want to read from a checklistbox content to send in play.

If you do :
Code: [Select]
_fileName = "e:\\mp3\\80mix\\One Shot 1980 [CD TWO]\\Gary Numan - Cars.mp3";
this.button1.Text = Path.GetFileName(_fileName);
ok.

---------------------

if you do so.

 _fileName = "" + checkedListBox1.Items.Contains(0).ToString() + "";

no play.
please?
help me.
« Last Edit: 12 Oct '07 - 16:58 by lab82 »

radio42

  • Posts: 4576
Re: played for checklistbox
« Reply #4 on: 12 Oct '07 - 17:09 »
Even if a little offside BASS ;-)

A "CheckedListBox" control hold a collection of objects in it's "Item" property.
If you add items to the listbox via:
Code: [Select]
string filename = "test.mp3";
...
int newIdx = checkedListBox1.Add(filename);
...
So assuming you have added 10 items to the listbox, you can access the object like this:
Code: [Select]
// via index
int idx = 0;
string filename = (string)checkedListBox1.Items[idx]
...
// or in a loop
foreach(string filename in checkedListBox1.Items)
{
   // do something with 'filename'
}

In your code above you are using the "Contains" method - which simply checks if an item exists - so this one returns a bool and not the string item!
For more info...check the .Net documentation.

lab82

  • Guest
Re: played for checklistbox
« Reply #5 on: 12 Oct '07 - 17:40 »
help!!

Code: [Select]
private void button1_Click(object sender, System.EventArgs e)
{
            int idx = 0;
            string FileName = (string)checkedListBox1.Items[idx];
            foreach (string _fileName in checkedListBox1.Items)
            {
                FileName = "" + FileName + "";          /* ERROR: ERROR: */
            this.button1.Text = Path.GetFileName(_fileName);
            }
         
  }

lab82

  • Guest
Re: played for checklistbox
« Reply #6 on: 12 Oct '07 - 17:47 »
hi, modify example "Simple" in directory:

C:\Program Files\BASS\.NET20\Samples\CS\Simple\

Help Me??. CheckBoxList1. ?

radio42

  • Posts: 4576
Re: played for checklistbox
« Reply #7 on: 12 Oct '07 - 20:02 »
I am a bit confused and don't know exactly what you are asking for?!

"checkedListBox1" was just an example, as I don't know how you have named your CheckedListBox instance member.
What do you want me to do with the sample "Simple" - as it does not contain any checkedlistbox today?