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


相关推荐

  • java集合概念_java多线程

    java集合概念_java多线程一、概述HashMap可能是我们最经常用的Map接口的实现了。话不多说,我们先看看HashMap类的注释:基于哈希表的Map接口实现。这个实现提供了所有可选的映射操作,并允许空值和空键。(Has

    2022年8月16日
    7
  • 断点续传过程中重复上传数据「建议收藏」

    断点续传过程中重复上传数据「建议收藏」断点续传过程中重复上传数据

    2022年4月25日
    53
  • OpenGL中的投影使用

    OpenGL中的投影使用

    2021年11月28日
    39
  • 尺度空间家具_空间尺度分析

    尺度空间家具_空间尺度分析尺度空间的基本思想:在视觉信息(图像信息)处理模型中引入一个被视为尺度的参数,通过连续变化尺度参数获得不同尺度下视觉处理信息,然后综合这些信息以深入地挖掘图像的本质特征。尺度空间方法将传统的单尺度视觉信息处理技术纳入尺度不断变化的动态构架中,因此更容易获得图像的本质特征。尺度空间生成的目的是模拟图像数据的多尺度特征。尺度空间理论是通过对原始图像进行尺度变换,获得图像多尺度下的尺度空间表示

    2022年8月31日
    3
  • securecrt乱码解决方法[通俗易懂]

    设置securecrt属性。问题securecrt连接某台linux机器显示中文乱码解决方法菜单下option-&gt;sessionoption1.选择图中属性结构中Emulation属性,修改terminal改成linux2.选择Appearance,在字符集属性中选择utf-8(具体要根据linux环境而定)…

    2022年4月10日
    42
  • 为ARM处理器实现Machine Forth「建议收藏」

    为ARM处理器实现Machine Forth「建议收藏」为ARM处理器实现MachineForth作者ReubenThomasComputerLaboratory,UniversityofCambridge23rdAugust1999摘要Fox和Moore[2]最近提出了一种新的Forth虚拟机模型,称为MachineForth。使用一个简单而具体的模型,据说它可以很容易地适应不同的硬件,不需要转向汇编

    2022年5月20日
    45

发表回复

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

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