|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
29.03.2009, 13:40 | #1 |
Пользователь
Регистрация: 29.03.2009
Сообщений: 12
|
Проигрователь mp3 на c++
Я тот решил написать проигрователь,ну не совсем сам,а спомощу книги.Получилась такая проблема,что я вроди всё правильно сделал,но нифига не пашет.Помогите!!Писал на C++Builder 6.
|
29.03.2009, 13:43 | #2 |
Пользователь
Регистрация: 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; } } |
29.03.2009, 13:43 | #3 |
Пользователь
Регистрация: 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 } //--------------------------------------------------------------------------- |
30.03.2009, 20:02 | #4 |
Unix C++ developer
Форумчанин
Регистрация: 16.04.2007
Сообщений: 651
|
Советую попробовать библиотеку bass.dll, в гугле запросто находится. умеет много чего в плане воспроизведения/обработки/визуализации звуковых файлов
|
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Перенисение скинов 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 |