線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1657
推到 Plurk!
推到 Facebook!

關於ActiveX MediaPlayer元件的問題?

尚未結案
evanlitw
一般會員


發表:3
回覆:4
積分:1
註冊:2003-07-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-02-01 13:33:53 IP:218.163.xxx.xxx 未訂閱
各位大大您好: 我使用了ActiveX的MediaPlayer元件來播放mp3 我要如何在它播放一首完畢後,會自動播放下一首 謝謝各位大大
mkbobo
一般會員


發表:4
回覆:68
積分:19
註冊:2003-04-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-02-09 17:04:18 IP:61.222.xxx.xxx 未訂閱
您好 感覺上您的問題跟activeX 沒啥關係 建議您可以先寫一個ap 測試好所有的功能 在將它放入activeX    MediaPlayer 裡面有一個 OnNotify 當撥放完畢時它會呼叫它    你可以參考一下下面的文章 http://delphi.ktop.com.tw/topic.php?topic_Id=18642 http://delphi.ktop.com.tw/topic.php?topic_Id=28749 相信可以找到你要的答案
ys168
初階會員


發表:3
回覆:24
積分:25
註冊:2005-10-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-11-14 22:08:55 IP:218.161.xxx.xxx 未訂閱
//---------------------------------------------------------------------------    #include  #pragma hdrstop #include "MP3PlayerU.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "WMPLib_OCX" #pragma resource "*.dfm" TForm1 *Form1; TStringList *fn = new TStringList(); int next=0; bool on_off=true; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void TForm1::FindFilesInDirectory(String directory, String extension, bool searchSubdir) { WIN32_FIND_DATA filedata ; // Structure for file data HANDLE filehandle ; // Handle for searching if( extension == "" ) extension = "*.*"; // Pass 1 - Search for the files within the directory. filehandle = FindFirstFile((directory extension).c_str(), &filedata) ; if( filehandle != INVALID_HANDLE_VALUE ) { do { if( (filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) { // Display the file name. TListItem *li = ListView1->Items->Add(); // dirPath = ExtractFileDir(directory filedata.cFileName); // dirPath=directory; fn->Add(directory filedata.cFileName); li->Caption = filedata.cFileName ; // Display the file extension. li->SubItems->Add(ExtractFileExt(filedata.cFileName)); /* // Display the file size. if( filedata.nFileSizeHigh == 0 ) { int filesize = filedata.nFileSizeLow 1023; if( filesize >= 1073741824 ) // 1024^3 li->SubItems->Add(String(filesize / 1073741824) " GB") ; else if( filesize >= 1048576 ) // 1024^2 li->SubItems->Add(String(filesize / 1048576) " MB") ; else li->SubItems->Add(String(filesize / 1024) " KB") ; // Add filesize to SubItems, for sorting file size purpose. li->SubItems->Add(String(filesize)); } else { // If nFileSizeHigh is non-zero then this is a **HUGE** file. double filesize = (MAXDWORD * filedata.nFileSizeHigh) filedata.nFileSizeLow; if( filesize >= 1073741824.0 ) // 1024^3 li->SubItems->Add(String(filesize / 1073741824.0) " GB") ; else if( filesize >= 1048576.0 ) // 1024^2 li->SubItems->Add(String(filesize / 1048576.0) " MB") ; else li->SubItems->Add(String(filesize / 1024.0) " KB") ; // Add filesize to SubItems, for sorting file size purpose. li->SubItems->Add(String(filesize)); } */ Application->ProcessMessages() ; } } while(FindNextFile(filehandle, &filedata)) ; FindClose(filehandle) ; } if(searchSubdir) // If user wanna search subdirectories.. { // Pass 2 - Search for all the subdirectories within this directory filehandle = FindFirstFile ((directory "*.*").c_str (), &filedata) ; if( filehandle != INVALID_HANDLE_VALUE) { do { if( (filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && String (filedata.cFileName) != "." && String (filedata.cFileName) != "..") { // Recursive call here FindFilesInDirectory(directory filedata.cFileName "\\", extension, true) ; } Application->ProcessMessages() ; } while(FindNextFile(filehandle, &filedata)) ; FindClose(filehandle) ; } Application->ProcessMessages() ; } } //------------------------------------------------------------------------- // 檔案區點選資料 void __fastcall TForm1::ListView1Click(TObject *Sender) { WindowsMediaPlayer1->controls->stop(); next =ListView1->Selected->Index; IWMPMediaPtr media = WindowsMediaPlayer1->mediaCollection->add(WideString(fn->Strings[next]).c_bstr()); WindowsMediaPlayer1->URL = media->get_sourceURL(); WindowsMediaPlayer1->controls->play(); Form1->Caption=ExtractFileDir(fn->Strings[next]); StatusBar1->Panels->Items[0]->Text="檔名︰" ExtractFileName(fn->Strings[next]); StatusBar1->Panels->Items[1]->Text= "Index︰【" IntToStr(next) "】"; StatusBar1->Panels->Items[2]->Text= "Total︰〔" IntToStr(fn->Count-1) "〕"; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { RadioGroup1->ItemIndex=0; Animate1->Visible=false; } //--------------------------------------------------------------------------- // 蒐集媒體資料 void __fastcall TForm1::ToolButton1Click(TObject *Sender) { String extend,dir; Animate1->Visible=true; Animate1->Active=true; switch(RadioGroup1->ItemIndex) { case 0: extend="*.mp3"; break; case 1: extend="*.WAV"; break; case 2: extend="*.MIDI"; break; case 3: extend=""; break; } dir= DriveComboBox1->Drive; ListView1->Items->Clear(); FindFilesInDirectory(dir AnsiString(":\\"), extend.c_str(), true); // 全部格式 Animate1->Active=false; Animate1->Visible=false; ToolButton1->Enabled=false; } //--------------------------------------------------------------------------- // 網路廣播 void __fastcall TForm1::RadioGroup2Click(TObject *Sender) { switch(RadioGroup2->ItemIndex) { case 0: WindowsMediaPlayer1->controls->stop(); // 台北之音 WindowsMediaPlayer1->URL="mms://203.187.31.160/fm1077"; WindowsMediaPlayer1->controls->play(); break; case 1: WindowsMediaPlayer1->controls->stop();// 綠色和平廣播電台 WindowsMediaPlayer1->URL="http://voiceoftaiwan.streamguys.com:7040"; WindowsMediaPlayer1->controls->play(); break; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { int mode=WindowsMediaPlayer1->playState; if(mode==1 && on_off==true) { next ; ListView1->Items->Item[next]->Selected; IWMPMediaPtr media = WindowsMediaPlayer1->mediaCollection->add(WideString(fn->Strings[next]).c_bstr()); WindowsMediaPlayer1->URL = media->get_sourceURL(); WindowsMediaPlayer1->controls->play(); ListView1->Items->Item[next]->Selected=true; ListView1->SetFocus(); Form1->Caption=ExtractFileDir(fn->Strings[next]); StatusBar1->Panels->Items[0]->Text="檔名︰" ExtractFileName(fn->Strings[next]); StatusBar1->Panels->Items[1]->Text= "Index︰【" IntToStr(next) "】"; //StatusBar1->Panels->Items[2]->Text= "Total︰〔" IntToStr(fn->Count-1) "〕"; } } //--------------------------------------------------------------------------- void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) { delete fn; } //--------------------------------------------------------------------------- void __fastcall TForm1::DriveComboBox1Change(TObject *Sender) { ToolButton1->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TForm1::ToolButton2Click(TObject *Sender) { if(on_off) // 按鍵浮上= 自動 { Timer1->Enabled=true; ToolButton2->Down=true; on_off=false; ToolButton2->Hint="自動下一曲目。"; } else { // 按鍵凹下= 手動 Timer1->Enabled=false; ToolButton2->Down=false; on_off=true; ToolButton2->Hint="取消下一曲目。"; } } //--------------------------------------------------------------------------- yangshuh
------
yangshuh
系統時間:2024-05-02 12:15:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!