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


相关推荐

  • IntelliJ IDEA使用教程(新手入门–持续更新)[通俗易懂]

    IntelliJ IDEA使用教程(新手入门–持续更新)[通俗易懂]idea使用教程一、下载安装二、基础配置及插件安装1.基础配置1.1配置jdk1.2配置maven1.3配置git1.4开启自动编译1.5调整字体(参照配置入口,大家可以根据喜好自行调整,记得调整完每一步都要点击apply)1.6取消大小写敏感,取消勾选1.7设置统一编码为utf-82、插件下载2.1[Mybatis](https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html)2.2[Lombok](https://www.zhihu.com/q

    2022年8月29日
  • asp判断session是否为空

    asp判断session是否为空1IfSession(“sesName”)=””Then…2IfSession(“sesName”)=EmptyThen…3IfIsEmpty(Session(“sesName”))Then…4IfCint(Session(“sesName”))=0Then… 来自:百度空间

    2022年7月15日
  • python常用模块大全_python3内置模块大全

    python常用模块大全_python3内置模块大全mathmath.ceil(a):用来返回≥a的最小整数math.floor(a):用来返回≤a的最大整数round(a[,b])如果没有参数b,只有a,round()作用是四舍五入如果

    2022年7月30日
  • rtsp视频流下载_rtmp网页视频播放器

    rtsp视频流下载_rtmp网页视频播放器在线视频流地址:rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov模拟器显示界面:学好一门语言,动手去练,半天上手,一星期炉火纯青。——专攻无人车的学长

    2022年9月13日
  • Android手机端编程开发软件合集(一)

    Android手机端编程开发软件合集(一)在网上搜索了很久才找到的编程IDE高级解锁版,在这里记录并分享一下吧!一、合集地址:蓝奏云:https://huanxingke.lanzous.com/b0203kqjg密码:flyingdream二、软件合集截图如下:三、软件的一些介绍:★文件1:【QPython3H.apk】(1)Python编辑器。(2)优点:文件交互简单,界面简洁友好,支持androidhelper,可以很方便地调用Android的API。(3)缺点:支持的第三方库较少,无代码预测。(4)网上的介绍:

    2022年5月24日
  • pycharm默认主题_pycharm主题插件

    pycharm默认主题_pycharm主题插件一、Pycharm基本设置(小白篇)1、打开Pycharm设置,【File】-【Settings】2、设置解释器,【File】-【Settings】-【Project:项目名字】-【ProjectInterpreter】-【设置图标】-【Add】-【浏览到目标解释器】,选择相应解释器即可。3、设置pycharm主题,【File】-【Settings】-【Appearance&Behavior】-【Appearance】;Theme:修改主题、Usecustomf

    2022年8月26日

发表回复

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

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