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


相关推荐

  • drf 教程_drm限制

    drf 教程_drm限制一、drf的安装1djangorestframework:django的app,只能再django上使用-djangorestframework是django的一个app,更快速在django框

    2022年8月6日
    1
  • pycharm2021.3.2激活码3月最新在线激活「建议收藏」

    pycharm2021.3.2激活码3月最新在线激活,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月15日
    328
  • Latex安装教程 (TeX Live 和 TeXStudio)

    Latex安装教程 (TeX Live 和 TeXStudio)文章目录TeXLive安装(1)进入官网[TexLive](http://tug.org/texlive/)(2)选择onDVD(3)选择downloadingtheTeXLiveISOimageandburningyourownDVD(4)选择downloadfromanearbyCTANmirror(5)选择texlive2020.iso下载(6)下载后解压:在解压后的文件中右击install-tl-windows->以管理员身份运行(7

    2022年5月25日
    52
  • 虚拟存储管理技术概念_虚拟内存管理

    虚拟存储管理技术概念_虚拟内存管理页内虚拟存储器页的大小是固定的段式虚拟存储器段的大小不固定段页式虚拟存储器把程序按逻辑结构分段,每段再划分为固定大小的页,主存空间也划分为大小相等的页,程序对主存的调入、调出仍以页为基本传送单位。每个程序对应一个段表,每段对应一个页表。虚拟地址:段号+段内页号+页内地址…

    2022年9月26日
    0
  • 阿里开源数据同步工具–DataX

    阿里开源数据同步工具–DataX下载地址:QuickStartDataX是异构数据源离线同步工具。能够将MySQLsqlServerOracleHiveHBaseFTP之间进行稳定高效的数据同步。设计思路:网状连接-》星型连接目前支持哪些数据同步?:核心架构:推荐使用python2.67不要使用python3,0使用方法和案例:1.准备一个job….

    2022年6月28日
    50
  • Group Convolution 分组卷积

    Group Convolution 分组卷积GroupConvolution分组卷积最早见于AlexNet——2012年Imagenet的冠军方法,GroupConvolution被用来切分网络,使其在2个GPU上并行运行,AlexNet网络结构如下:ConvolutionVSGroupConvolution如果输入featuremap尺寸为C∗H∗W,卷积核有N个,输出featuremap与卷积核的数量相同也是N,每…

    2022年10月26日
    0

发表回复

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

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