使用 mciSendString()函数利用 mci 字符串来实现单首歌曲循环播放或多首歌曲切换播放
作者:遇见恒星
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib")
#include <string>
using namespace std;
char buf[50];
MCIERROR mcierror;
string song_name,mci_string;
char +me_all[60];
int dwlong;
bool -rst_song=true;
void play();
void main()
{
song_name="给我一首歌的时间.mp3";
-rst_song=false;
play();
while (1)
{
mciSendString("status 设备 1 posi+on",buf,sizeof(buf),NULL);//获取播放歌曲的
进度,
int posi+on=atoi(buf);//转化为整型数据
prin8("当前进度:%d",posi+on);
if(posi+on>=dwlong)
{
mciSendString("close 设备 1",buf,sizeof(buf),NULL); //这一布至关重要,要
先把已经播放完的设备先关闭,因为不能够出现同名的设备名“设备 1”!!
if (-rst_song==false)
{
song_name="少年行.wma";
-rst_song=true;
}
else
{
song_name="给我一首歌的时间.mp3";
- 1
- 2
- 3
- 4
- 5
前往页