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)
上一篇 2022年4月6日 下午7:20
下一篇 2022年4月6日 下午7:20


相关推荐

  • PS2有线手柄的SPI协议

    PS2有线手柄的SPI协议1.SPI模式与PS2采用的是SPIMODE3模式。并且使用低位在前方式收发数据。2.请求PS2按键数据想要向PS2请示数据要发送一个请求命令。请求命令如下所示:cmd_require[9]={0x01,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//数据按先低位后高位发送3.接收PS按键数据在发送请求命令的…

    2022年5月6日
    53
  • 探索SQL Server元数据(一)

    探索SQL Server元数据(一)

    2021年11月28日
    40
  • PyCharm常用设置(图解)

    PyCharm常用设置(图解)1.保存设置pycharm中的设置是可以导入和导出的,file>exportsettings可以保存当前pycharm中的设置为jar文件保存在桌面上2.导入设置重装时可以直接importsettings>jar文件,就不用重复配置了确认是否要导入点击确认重新启动3.设置Python自动引入包设置Python自动引入包,要先在…

    2022年8月27日
    8
  • uni-app之nvue的使用详解

    uni-app之nvue的使用详解一 为什么要使用 nvue 小程序和 App 的 vue 页面 主体是 webview 渲染的 为了提升性能 小程序和 App 的 vue 页面下部分 ui 元素 比如导航栏 tabbar video map 使用了原生控件 详见 原生组件使用说明 这种方式被称为混合渲染 虽然提升了性能 但原生组件带来了其他问题 前端组件无法覆盖原生控件的层级问题 原生组件不能嵌入特殊前端组件 如 scroll view swip

    2026年3月19日
    3
  • Redis设置过期时间_redis过期时间原理

    Redis设置过期时间_redis过期时间原理varredis=require(‘redis’),RDS_PORT=6389,//端口号RDS_HOST=’127.0.0.1′,//服务器IPRDS_PWD=’88888888888888′,//密码RDS_OPTS={},//设置项rclient=redi…

    2026年4月14日
    4
  • shiro框架的使用_ug星空安装步骤

    shiro框架的使用_ug星空安装步骤1.Shiro框架详解一、Shiro能干什么&amp;nbsp;ApacheShiro是一个强大易用的Java安全框架,提供了认证、授权、加密和会话管理等功能:&amp;nbsp;认证-用户身份识别,常被称为用户“登录”;授权-访问控制;密码加密-保护或隐藏数据防止被偷窥;会话管理-每用户相关的时间敏感的状态。对于…

    2025年10月7日
    8

发表回复

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

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