在BCB中如何实现程序同时播放背景(MIDI)音乐和前景(WAV)声音?(在VB中能实现)

yg2000 2001-07-20 12:53:12
...全文
437 21 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
szchengyu 2001-12-01
  • 打赏
  • 举报
回复
g z
yg2000 2001-07-27
  • 打赏
  • 举报
回复
dingzhenhhy(人言落日是天涯,望及天涯不见家(快疯了) 你好!! 我打开文件真有Form4,顺便加上了 MediaPlayer控件,设好了有关属性,运行后播放了MIDI音乐,当我一拖动音量条
立刻不响了,现象跟以前说的一样。你能不能把FORM4中的音量控制放到FORM1中或在FORM4中
加上MediaPlayer控件,设好有关属性进行控制MIDI和WAV音量呢?如果能实现再告诉我好吗!
我先谢谢你了!!!!到时兄弟一定在下一主题中给高分!!!!!
补充:你的程序运行后,进不到FORM4怎样能控制到FORM1里的音量呢?从代码中我看不出能起
到控制音量的作用。
路人丁 2001-07-27
  • 打赏
  • 举报
回复
兄弟有的!那个媒体播放程序!form4里就是调节音量!
yg2000 2001-07-27
  • 打赏
  • 举报
回复
同时播放MIDI和WAV或AVI文件问题解决了,但怎样在自已做的界面中调节音量的问题还未解决。现在先给有功者进分。
yg2000 2001-07-25
  • 打赏
  • 举报
回复
 NowCan(能量、激情、雨水、彩虹——雷雨云) 你好!你的E_Mail我收到了,并且给你回了信。
yg2000 2001-07-23
  • 打赏
  • 举报
回复
dingzhenhhy(人言落日是天涯,望及天涯不见家(快疯了)你好!!问题解决了,感谢你的帮助。我在主题:(用MediaPlayer1和MediaPlayer2能同时播放Mid和Wav或Avi文件,但是Avi文件中的图象却出不来,而只有声音,不知为什么?请高手帮帮忙。)中解决的。有空我再试试你的方法。另外的主题是::如何用Scroollbor控件来预先设置音量大小的程序?你若知道帮帮我,分到时一起给。

 
路人丁 2001-07-23
  • 打赏
  • 举报
回复
我的试验:
#include <mmsystem.h>//包含头文件
sndPlaySound("d:\\sundtest\\wmpaud1.wav",SND_ASYNC);//函数播放
MediaPlayer1->FileName="F:\丁振编程区\Tetris\BGSound.mid";//媒体播放器的设置
我试验了这个是好用的。
注意:两个文件扩展名不同!
对于相同的wav不能播放其它的没有试验。
路人丁 2001-07-23
  • 打赏
  • 举报
回复
这几天有事没来!抱歉。
我是大概是这样做的(时间太久了源程序没了)
#include <vcl\mmsystem.hpp>//头文件
sndPlaySound("warning.wav",SND_SYNC);//播放方式
对于媒体播放器,的设置没什么特别的要求,好像是要要先用媒体播放器,后启动api。
你在实验一下我也给你试验一下,(不过太忙了,不知能不能帮你)
alang_xy 2001-07-22
  • 打赏
  • 举报
回复
有意思!
yg2000 2001-07-22
  • 打赏
  • 举报
回复
dingzhenhhy(人言落日是天涯,望及天涯不见家(快疯了)你好! 你这条语句
{BOOL sndPlaySound(LPCSTR lpszSound, UINT fuSound); }怎么用,假如
我的文件在{c:\005.wav}下,c:\005.wav文件怎么写入函数 sndPlaySound()中?

这是怎么回事?
1.
sndPlaySound("c:\windows\ding.wav",SND_ASYNC); //有一声windows中的“Beep”声
sndPlaySound("c:\windows\yg2000.wav",SND_ASYNC);//换文件后也是一样的效果
2.
sndPlaySound("c:\windows",SND_ASYNC); //无反应
BOOL sndPlaySound(LPCSTR lpszSound, UINT fuSound); //无反应

3.
我BCB中的Animate和TMediaPlayer控件虽然能播AVI,但只有声音无图象。
Animate的Active属性也设不了True.
4.在VB中用二个相同的控件(MMcontrol或MCiwnd)各播各的就行了,在BCB中我
真的服了.




NowCan 2001-07-22
  • 打赏
  • 举报
回复
用函数 sndPlaySound()播放wav(异步),用多媒体播放控件播放mid,绝对没问题,我实现过的。
yg2000 2001-07-22
  • 打赏
  • 举报
回复
NowCan(能量、激情、雨水、彩虹——雷雨云)和: dingzhenhhy(人言落日是天涯,望及天涯不见家(快疯了) 你们好,能否举个例子利用一个Form1t和相关的控件写出代码好吗? 我的E-mail:nanbeizhong0492@sina.com 
yg2000 2001-07-22
  • 打赏
  • 举报
回复
wxz 你好!

椐我在VB中的实践,Midi和Avi或Wav可以用一种控件来播,但不能同时播Avit和WAV文件。

Windows支持两种RIFF(resource interchange file format,“资源交互文件格式”)音频文件:MIDI的RMID文件和波形音频文件格式WAV文件,用sndPlaySound播放音频文件使用是很简单的。但是用sndPlaySound播放音频文件有一个限制,即整个音频文件必须全部调入可用的物理内存。因此应用sndPlaySound播放的音频文件相对较小,最大约100K。要播放大一些的音频文件(在多媒体设计中是经常要遇到的情况)需要使用MCI的功能。因此我想用二种控件来解决它,不知能否实现。

下面你写的一段代码帮我看一下怎么实现。
播放wav和Avi用MediaPlayer
播放midi用mci,代码如下:

打开设备: //代码放什么地方?写到FormOnCreate上,运行时在下面的 "MCIERROR mciError;"上通不过。
MCIERROR mciError;
char outBuf[100];
AnsiString Cmd="open ";
Cmd=Cmd+File+ " type sequencer alias "+Alias; //"type sequencer alias "怎么用
// File:midi文件
mciError=mciSendString(
Cmd.c_str(),outBuf,sizeof(outBuf),File);
if(mciError)
{
mciGetErrorString(mciError,outBuf,sizeof(outBuf));
Application->MessageBox(outBuf,"错误",
MB_SYSTEMMODAL+MB_OK+ MB_ICONSTOP);
}



播放midi://是写到控件上的单击事件上吧?或写到FormOnCreate上吧?
AnsiString Cmd="play ";
Cmd=Cmd+" "+Alias+" notify"; //怎么用"Alias"?我写上文件也不好使。
HWND hWnd=Application->Handle;
MCIERROR mciError=mciSendString(Cmd.c_str(),NULL,0,hWnd);
if(mciError)
{
char Buf[100];
mciGetErrorString(mciError,Buf,sizeof(Buf));
Application->MessageBox(Buf,"错误",
MB_SYSTEMMODAL+MB_OK+ MB_ICONSTOP);
}
路人丁 2001-07-21
  • 打赏
  • 举报
回复
用函数 sndPlaySound()播放一个(异步)
再用那个多媒体播放控件(MediaPlayer)播放一个
绝对没问题,我用过。
我不懂电脑 2001-07-20
  • 打赏
  • 举报
回复
用多线程吧,一个放背景,一个放前景
dycdyc123 2001-07-20
  • 打赏
  • 举报
回复
bcb中有这样的控件TMediaPlayer
试试??
但注意设置其驱动设备!
yg2000 2001-07-20
  • 打赏
  • 举报
回复
椐我在VB中的实践,Midi和Avi或Wav可以用一种控件来播,但不能同时播Avit和WAV文件。

Windows支持两种RIFF(resource interchange file format,“资源交互文件格式”)音频文件:MIDI的RMID文件和波形音频文件格式WAV文件,用sndPlaySound播放音频文件使用是很简单的。但是用sndPlaySound播放音频文件有一个限制,即整个音频文件必须全部调入可用的物理内存。因此应用sndPlaySound播放的音频文件相对较小,最大约100K。要播放大一些的音频文件(在多媒体设计中是经常要遇到的情况)需要使用MCI的功能。因此我想用二种控件来解决它,不知能否实现。

下面一段代码帮我看一下怎么实现。
播放wav和Avi用MediaPlayer
播放midi用mci,代码如下:

打开设备: //代码放什么地方?写到FormOnCreate上,运行时在下面的 "MCIERROR mciError;"上通不过。
MCIERROR mciError;
char outBuf[100];
AnsiString Cmd="open ";
Cmd=Cmd+File+ " type sequencer alias "+Alias; //"type sequencer alias "怎么用
// File:midi文件
mciError=mciSendString(
Cmd.c_str(),outBuf,sizeof(outBuf),File);
if(mciError)
{
mciGetErrorString(mciError,outBuf,sizeof(outBuf));
Application->MessageBox(outBuf,"错误",
MB_SYSTEMMODAL+MB_OK+ MB_ICONSTOP);
}



播放midi://是写到控件上的单击事件上吧?或写到FormOnCreate上吧?
AnsiString Cmd="play ";
Cmd=Cmd+" "+Alias+" notify"; //怎么用"Alias"?我写上文件也不好使。
HWND hWnd=Application->Handle;
MCIERROR mciError=mciSendString(Cmd.c_str(),NULL,0,hWnd);
if(mciError)
{
char Buf[100];
mciGetErrorString(mciError,Buf,sizeof(Buf));
Application->MessageBox(Buf,"错误",
MB_SYSTEMMODAL+MB_OK+ MB_ICONSTOP);
}

初学者等待回音,我再加30分。
wjzhuang 2001-07-20
  • 打赏
  • 举报
回复
学习
BCB 2001-07-20
  • 打赏
  • 举报
回复
异步方式可以同时放,不用多线程
路人丁 2001-07-20
  • 打赏
  • 举报
回复
BOOL sndPlaySound(LPCSTR lpszSound, UINT fuSound);



Plays a waveform sound specified either by a filename or by an entry in the registry or the WIN.INI file. This function offers a subset of the functionality of the PlaySound function; sndPlaySound is being maintained for backward compatibility.

?Returns TRUE if successful or FALSE otherwise.

lpszSound

A string that specifies the sound to play. This parameter can be either an entry in the registry or in WIN.INI that identifies a system sound, or it can be the name of a waveform-audio file. (If the function does not find the entry, the parameter is treated as a filename.) If this parameter is NULL, any currently playing sound is stopped.

fuSound

Flags for playing the sound. The following values are defined:

SND_ASYNC

The sound is played asynchronously and the function returns immediately after beginning the sound. To terminate an asynchronously played sound, call sndPlaySound with lpszSoundName set to NULL.

SND_LOOP

The sound plays repeatedly until sndPlaySound is called again with the lpszSoundName parameter set to NULL. You must also specify the SND_ASYNC flag to loop sounds.

SND_MEMORY

The parameter specified by lpszSoundName points to an image of a waveform sound in memory.

SND_NODEFAULT

If the sound cannot be found, the function returns silently without playing the default sound.

SND_NOSTOP

If a sound is currently playing, the function immediately returns FALSE, without playing the requested sound.

SND_SYNC

The sound is played synchronously and the function does not return until the sound ends.

If the specified sound cannot be found, sndPlaySound plays the system default sound. If there is no system default entry in the registry or WIN.INI file, or if the default sound cannot be found, the function makes no sound and returns FALSE.
The specified sound must fit in available physical memory and be playable by an installed waveform-audio device driver. If sndPlaySound does not find the sound in the current directory, the function searches for it using the standard directory-search order.
加载更多回复(1)

13,871

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧