libzplay开发【播放音乐】笔记1
2012-11-26 09:49
232 查看
库方面的配置网上都有
/*
* libZPlay example
*
* Play test.mp3 to sound card output.
*
*/
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "libzplay.h"
using namespace libZPlay;
int main(int argc, char **argv)
{
printf("Playing test.mp3\n\nPress q to end\n\n");
// create class instance using class factory.
ZPlay *player = CreateZPlay();
// open file
int result = player->OpenFile("test.mp3", sfAutodetect);
if(result == 0)
{
// display error message
printf("Error: %s\n", player->GetError());
player->Release();
return 0;
}
// get song length
TStreamInfo info;
player->GetStreamInfo(&info);
printf("Length: %02u:%02u:%02u:%03u\n\n", info.Length.hms.hour,
info.Length.hms.minute,
info.Length.hms.second,
info.Length.hms.millisecond);
// start playing
player->Play();
// display position and wait for song end
while(1)
{
// check key press
if(kbhit())
{
int a = getch();
if(a == 'q' || a == 'Q')
break; // end program if Q key is pressed
}
// get stream status to check if song is still playing
TStreamStatus status;
player->GetStatus(&status);
if(status.fPlay == 0)
break; // exit checking loop
// get current position
TStreamTime pos;
player->GetPosition(&pos);
// display position
printf("Pos: %02u:%02u:%02u:%03u\r", pos.hms.hour, pos.hms.minute, pos.hms.second, pos.hms.millisecond);
Sleep(300); // wait 300 ms
}
// destroy class instance
player->Release();
return 0;
}
/*
* libZPlay example
*
* Play test.mp3 to sound card output.
*
*/
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "libzplay.h"
using namespace libZPlay;
int main(int argc, char **argv)
{
printf("Playing test.mp3\n\nPress q to end\n\n");
// create class instance using class factory.
ZPlay *player = CreateZPlay();
// open file
int result = player->OpenFile("test.mp3", sfAutodetect);
if(result == 0)
{
// display error message
printf("Error: %s\n", player->GetError());
player->Release();
return 0;
}
// get song length
TStreamInfo info;
player->GetStreamInfo(&info);
printf("Length: %02u:%02u:%02u:%03u\n\n", info.Length.hms.hour,
info.Length.hms.minute,
info.Length.hms.second,
info.Length.hms.millisecond);
// start playing
player->Play();
// display position and wait for song end
while(1)
{
// check key press
if(kbhit())
{
int a = getch();
if(a == 'q' || a == 'Q')
break; // end program if Q key is pressed
}
// get stream status to check if song is still playing
TStreamStatus status;
player->GetStatus(&status);
if(status.fPlay == 0)
break; // exit checking loop
// get current position
TStreamTime pos;
player->GetPosition(&pos);
// display position
printf("Pos: %02u:%02u:%02u:%03u\r", pos.hms.hour, pos.hms.minute, pos.hms.second, pos.hms.millisecond);
Sleep(300); // wait 300 ms
}
// destroy class instance
player->Release();
return 0;
}
相关文章推荐
- Android开发笔记之广播,service实现音乐的播放暂停停止快进等功能
- 【Cocos2D-X游戏开发笔记1】播放音乐&CocosDenshion
- android开发笔记之多媒体—播放音频(音乐)
- android开发中的小段音乐播放
- [IOS 开发] iOS音频篇:使用AVPlayer播放网络音乐
- [IOS 开发] iOS音频篇:使用AVPlayer播放网络音乐
- iOS开发笔记--开源播放框架ijkplayer(iOS版)使用教程
- Android开发笔记——视频录制播放常见问题
- Android开发本地及网络Mp3音乐播放器(四)实现音乐播放
- iOS开发小技巧(视频和音乐播放)
- Android VLC播放器二次开发3——音乐播放(歌曲列表+歌词同步滚动)
- iOS开发系列--扩展--播放音乐库中的音乐
- 从零到有开发一个DJ舞曲音乐播放兼视频播放的可可APP
- iOS开发拓展篇—音乐的播放
- Android VLC播放器二次开发3——音乐播放(歌曲列表+歌词同步滚动)
- iOS开发-音乐播放(AVAudioPlayer)
- [开发笔记]-flowplayer视频播放插件
- Qt游戏开发必备!用QtMultimedia播放Ogg格式音乐
- iOS开发之音乐播放----监听耳机拔插
- Android开发本地及网络Mp3音乐播放器(四)实现音乐播放