libzplay开发【播放音乐】笔记1

库方面的配置网上都有/**libZPlayexample**Playtest.mp3tosoundcardoutput.**/#include”stdafx.h”#include#include#include#include”libzplay.h”usingnamespacelibZPlay;intmain(in

大家好,又见面了,我是你们的朋友全栈君。

库方面的配置网上都有

/*
* 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;
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/125890.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • leavecriticalsection报错_sequence的用法

    leavecriticalsection报错_sequence的用法线程锁的概念函数EnterCriticalSection和LeaveCriticalSection的用法注:使用结构CRITICAL_SECTION需加入头文件#include“afxmt.h”定义一个全局的锁CRITICAL_SECTION的实例和一个静态全局变量CRITICAL_SECTIONcs;//可以理解为锁定一个资源statici

    2026年1月31日
    3
  • TYVJ P1032 零用钱 Label:贪心

    TYVJ P1032 零用钱 Label:贪心

    2021年9月17日
    65
  • 深圳IT外包公司名单汇总

    深圳IT外包公司名单汇总开科唯识汉克时代拓维云创旭阳软件赛意信息金证股份博颜科技得逸信息新致软件兴融联通通互联信必优易宝长亮科技紫川软件文思海辉东软睿服科技拓保软件联龙汉克润和三丈信息信达体育文化京北方佰钧成亿达新致华云信息纬创软件合生科技海万信息Pactura维沃法本德科中软国际软通动力大展科技天阳博奥特先进数通融安易立德人瑞云盈网络中科软科锐国际湃腾点点新致煜象科技泛鹏天地…

    2022年6月3日
    100
  • Java实现判断闰年

    Java实现判断闰年Java实现闰年判断需求分析:年份如果满足以下两个条件中的其中一个则可将其年份判断位闰年一、能被4整除,但不能被100整除,就是闰年;二、能被400整除,也是闰年;需求实现方案一:使用if的嵌套实现packagecom.qingsu.basis;importjava.util.Scanner;publicclassProcessControl{ publicstaticvoidmain(String[]args){ //判断闰年 //1.能被4整除

    2022年7月17日
    19
  • Python range() 函数用法

    Python range() 函数用法

    2021年10月21日
    61

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号