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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • MongoDB基本操作

    MongoDB基本操作MongoDB基本操作

    2022年4月25日
    43
  • centos7 rabbitmq安装_阿里云 k8s

    centos7 rabbitmq安装_阿里云 k8s我这里使用三台阿里云服务器搭建RabbitMQ集群。1.首先使用cat/etc/hostname查看自己这三台云服务器的名字。当然也可以按照自己的想法修改,使用vim/etc/hostname就可已修改,如何进行编辑和保存,可以百度搜一下。保存之后,需要重启云服务器才能生效。图中1和2都是hostname,修改过/etc/hostname之后,必须重启之后,1和/etc/hostname的值才能一样。2.使用vim/etc/hosts填写下边的格式的内容:xxx.xxx.xxx.xxxh

    2025年10月18日
    4
  • python-PyPDF2

    python-PyPDF2作用:处理PDF文档提取文本,旋转页面,叠加页面1.pdfFileObj=open(‘meetingminutes.pdf’,’rb’)#打开pdf文档2.pdfReader=PyPDF2.PdfFileReader(pdfFileObj)#获取pdf文档数据3.pdfReader.numPages#获取页数4.pageObj=pdfReader.getPage(0)#获取指定页码的内…

    2022年6月23日
    30
  • JsonNode、JsonObject常用方法[通俗易懂]

    JsonNode、JsonObject常用方法[通俗易懂]jsonNode,fastJson常用的方法

    2022年7月12日
    54
  • bytebuffer.putint_get的用法和例句

    bytebuffer.putint_get的用法和例句最近再看java的NIO,里面提到了几个基本的类,其中ByteBuffer是最基础的,用于Channel的读写传输数据使用。下面总结一下我理解的ByteBuffer。先从代码开始分析staticpublicvoidasIntBuffer(){ByteBufferbBuf=ByteBuffer.allocate(512);bBuf.putI

    2022年10月2日
    3
  • currentStyle使用示例[通俗易懂]

    currentStyle使用示例[通俗易懂]currentStyle使用示例Dom中的currentStyle属性.从字面上理解这是当前样式风格.没错currentStyle就是用来获取元素内Css的style样式属性值.比如说元素的width值height值.甚至元素的文本排放方式text-align,包括

    2022年7月14日
    20

发表回复

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

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