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


相关推荐

  • windows10 安装密钥_安装了pycharm还需要安装anaconda

    windows10 安装密钥_安装了pycharm还需要安装anaconda前言Python环境配置,有很多种组合方式,但是比较流行的是:Anaconda+Pycharm.第一部分:下载及安装Anaconda1.下载Anaconda安装包,官网下载地址:https://www.anaconda.com/download/选择64-bit的python3.7下载安装Anaconda下载后的文件为.exe文件,双击该文件进入安装界面。  2.1、依次…

    2022年8月29日
    2
  • STM32驱动ST7701S芯片(vⅰV0手机换屏价)

    1、配置GPIO口voidLCD_GPIO_Config(void){/*定义一个GPIO_InitTypeDef类型的结构体*/GPIO_InitTypeDefGPIO_InitStructure;/*????IO??*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE…

    2022年4月11日
    360
  • python写学生信息管理系统代码_学生管理系统源码

    python写学生信息管理系统代码_学生管理系统源码一、前言相信很多小伙伴在学校期间都会被要求实现一个学生管理系统,很多是让用C语言实现,有的是要求Python。这里通过python实现了一个学生管理系统,考试/交作业必备!二、实现效果三、完整源码defindex():”””管理系统主页”””print(“*”*30)print(“Python学生管理系统\n\n1.添加学生的信息\n2.删除学生的信息\n3.修改学生的信息\n4.查询学生的信息\n5.查询所有学生的信息\n6.退出系统

    2025年11月27日
    2
  • Error:Execution failed for task ‘:app-doc:packageDebug’. > java.io.IOException: Failed to read zip解决

    Error:Execution failed for task ‘:app-doc:packageDebug’. > java.io.IOException: Failed to read zip解决

    2021年3月12日
    172
  • mysql 锁表详解

    mysql 锁表详解为了给高并发情况下的MySQL进行更好的优化,有必要了解一下mysql查询更新时的锁表机制。一、概述MySQL有三种锁的级别:页级、表级、行级。MyISAM和MEMORY存储引擎采用的是表级锁(table-levellocking);BDB存储引擎采用的是页面锁(page-levellocking),但也支持表级锁;InnoDB存储引擎既支持行级锁(row-levellocki

    2022年6月3日
    103
  • 金山词霸2009牛津版完整激活成功教程版+绿色精简版下载

    金山词霸2009牛津版完整激活成功教程版+绿色精简版下载山软件推出了最新的《金山词霸2009牛津版》了!这次金山词霸与牛津合作,一次性增加6本牛津词典,这在牛津在全球的翻译软件合作伙伴中也属首次,实属不容易呢,可以说提升了金山词霸在翻译软件类中的权威和经典的形象了。    这次《金山词霸2009牛津版》里面内置了6本牛津词典:《新牛津英汉双解大词典》、《新牛津美语大词典》、《牛津英语习语词典》、《牛津短语动词词典》、《牛津英语搭配词典》、《牛津英语同义

    2022年7月15日
    17

发表回复

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

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