Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > C/C++ программирование > Общие вопросы C/C++
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 29.03.2009, 13:40   #1
Palach
Пользователь
 
Регистрация: 29.03.2009
Сообщений: 12
По умолчанию Проигрователь mp3 на c++

Я тот решил написать проигрователь,ну не совсем сам,а спомощу книги.Получилась такая проблема,что я вроди всё правильно сделал,но нифига не пашет.Помогите!!Писал на C++Builder 6.
Palach вне форума Ответить с цитированием
Старый 29.03.2009, 13:43   #2
Palach
Пользователь
 
Регистрация: 29.03.2009
Сообщений: 12
По умолчанию

#include <vcl.h>
#include<MPlayer.hpp>
#pragma hdrstop

#include "Unit1.h"

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{

}
#include<FileCtrl.hpp>

AnsiString SoundPath;
int min,sec;
int mode = 0;

union TVolume{
unsigned long Volume;
struct
{
Word Left;

Word Right;
};
} volume;
//-Начало работы программы-----
void __fastcall TForm1::FormCreate(TObject *Sender)
{
MediaPlayer1 = new TMediaPlayer(Form1->Handle);
PlayList("");

waveOutGetVolume(0,&volume.Volume);
TrackBar1->Position= - volume.Left;


ListBox1->Color = (TColor)RGB(56,176,222);
}
void __fastcall TForm1::PlayList(AnsString path)
{

TSearchRec SearchRec;

ListBox1->Clear();

if (FindFirst(path + "*.mp3", faAnyFile, SearchRec) !=0 )
{

SpeedButton2->Enabled = false;
SpeedButton3->Glyph->
LoadFromResourceID((int)HInstance,1 03);
SpeedButton4->Enabled = false;

Label1->Caption="";
return;
}
ListBox1->Items->Add(SearchRec.Name);
while (FindNext(SearchRec) == 0)
ListBox1->Items->Add(SearchRec.Name);

ListBox1->ItemIndex = 0;
Label1->Caption = ListBox1->Items->
Strings[ListBox1->ItemIndex];
SpeedButton2->Enabled = false;
if (ListBox1->Count ==1)
SpeedButton4->Enabled=false;
else
SpeedButton4->Enabled = true;
SpeedButton3->Glyph->
LoadFromResourceID(int)HInstance,10 1);


void __fastcall TForm1: :Play()
{
Label->Caption = ListBox1->Items->
Strings[ListBox1->ItemIndex];
MediaPlayer1->FileName = SoundPath +
ListBox1->Items->Strings[ListBox1->ItemIndex];


MediaPlayer1->Open();
MediaPlayer1->Play();

min = 0;
sec = 0;
Timer->Enabled = true;
}

void __fastcall TForm: :Stop()
{
MediaPlayer1->Stop()
Timer->Enabled = false;
Label2->Caption = "0";
Label3->Caption = "00";
}


void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
if (mode == 1)
{
SpeedButton3->Glyph->
LoadFromResourseID((int)HInstance,1 01);
SpeedButton3->Hint="Воспроизведение";
Stop();
mode = 0;
}
else{
SpeedButton3->Glyph->
LOadFromResourceID((int)HInstance,1 02);
SpeedButton3->Hint = "Стоп";
Play();
mode = 1;

}
}
Palach вне форума Ответить с цитированием
Старый 29.03.2009, 13:43   #3
Palach
Пользователь
 
Регистрация: 29.03.2009
Сообщений: 12
По умолчанию

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if (sec<59)
{
sec++;
if(sec<10
Label3->Caption = "0"+ IntToStr(sec);
else
Label3->Caption = IntToStr(sec);
}
else
{
sec = 0;
min++;
Label2->Caption = IntToStr(min);
Label3->Caption = "00";
}
if (MediaPlayer1->Position<MediaPlayer1->Length)
return;
Stop();

if (ListBox1->ItemIndex < ListBox1->Count - 1 )
{
ListBox1->ItemIndex +=1;
Play();

if (ListBox1->ItemIndex == ListBox->Count - 1)
SpeedButton4->Enable = false;
}
else{
SpeedButton->Glyph->
LoadFromResourceID((int)HInstance,1 01);
SpeedButton->Hint = "Воспроизведение";
mode = 0;
}

}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton4Click(TObject *Sender)
{
if (mode ==1)
Stop();
ListBox1->ItemIndex +=1;
Label1->Caption = ListBox1->
Items->Strings[ListBox1->ItemIndex];
if(ListBox1->ItemIndex == ListBox1->Count - 1)
SpeedButton4->Enabled = false;
if (! SpeedButton2->Enabled)
SpeedButton2->Enabled = true;
if (mode ==1)
Play();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
if (mode ==1)
Stop();
ListBox1->ItemIndex -= 1;
Label1->Caption = ListBox1->Items->
Strings[ListBox1->ItemIndex];
if ( ! SpeedButton4->Enabled)
SpeedButton4->Enabled = true;
if(ListBox1->ItemIndex == 0)
SpeedButton2->Enable = false;
if (mode == 1)
Play();

}
#include<FileCtrl.hpp>

//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
AnsiString dir;
if (SelectDirectory("Выберите каталог","",dir))
{
if (mode == 1)
{
Stop();

SpeedButton3->Glyph->
LoadFromResourceID((int)HInstance,1 01);
SpeedButton3->Hint = "Воспроизведение";
Stop();
mode = 0;
}
SoundPath = dir+"\\";
PlayList(SoundPath);
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
if (MediaPlayer1->Mode == 2)
{
Stop();
Play();
}
if (ListBox1->ItemIndex ==0)
SpeedButton2->Enabled = false;
else
SpeedButton2->Enabled = true;
if (ListBox1->ItemIndex == ListBox1->Count-1)
SpeedButton4->Enabled = false;
else
SpeedButton4->Enable = true;

}

#include <mmsystem.hpp>

//---------------------------------------------------------------------------

void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
volume.left = -TrackBar1->Position;
volume.Right = - TrackBar1->Position;
waveOutSetVolume(0,volume.Volume
}
//---------------------------------------------------------------------------
Palach вне форума Ответить с цитированием
Старый 30.03.2009, 20:02   #4
oleg kutkov
Unix C++ developer
Форумчанин
 
Аватар для oleg kutkov
 
Регистрация: 16.04.2007
Сообщений: 651
По умолчанию

Советую попробовать библиотеку bass.dll, в гугле запросто находится. умеет много чего в плане воспроизведения/обработки/визуализации звуковых файлов
oleg kutkov вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Перенисение скинов c winamp на мой проигрователь. DelphiMan Мультимедиа в Delphi 1 01.02.2009 06:51
Перенисение скинов c winamp на мой проигрователь. DelphiMan Мультимедиа в Delphi 1 31.01.2009 13:14
mp3 krok PHP 2 29.04.2008 11:21
MediaPlayer - как сделать последовательное воспроизведение mp3 файлов (именно mp3) Kashp Компоненты Delphi 13 28.09.2007 08:38