当前位置: 首页>>代码示例>>C++>>正文


C++ AudioPlayer::progress方法代码示例

本文整理汇总了C++中AudioPlayer::progress方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioPlayer::progress方法的具体用法?C++ AudioPlayer::progress怎么用?C++ AudioPlayer::progress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AudioPlayer的用法示例。


在下文中一共展示了AudioPlayer::progress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: playASound

int playASound(const char* fn){
    
    
    AudioPlayer* ap = AudioPlayer::file(fn);
    
    if(!ap) {
        std::cerr << "Error loading audio" << std::endl;
        return 1;
    }
    
    ap->play();
    
    char indic[] = { '|', '/', '-', '\\' };
    int i = 0;
    
    do {                                               // 5
        //        std::cout << "Loop." << std::endl;
        CFRunLoopRunInMode (                           // 6
                            kCFRunLoopDefaultMode,                     // 7
                            0.25,                                      // 8
                            false                                      // 9
                            );
        
        std::cout << "\rPlaying.. " << indic[i];
        
        double d = ap->progress();
        double min = floor(d/60);
        double sec = floor(fmod(d,60));
        std::cout << "   " << min << ":" << sec;
        
        d = ap->duration();
        min = floor(d/60);
        sec = floor(fmod(d,60));
        std::cout << "   " << min << ":" << sec;
        
        std::cout << std::flush;
        
        if(ap->progress() > 5) {
            ap->seek(rand()/(float(RAND_MAX))*ap->duration());
        }
        
        i = (i+1)%4;
    } while (ap->isPlaying());
    
    delete ap;
    
    return 1;
}
开发者ID:LindongLi,项目名称:Conductor,代码行数:48,代码来源:AudioPlayer.cpp

示例2: main

int main() {


    const char *fn = "WRECKINGBALL.wav";

    AudioPlayer* ap = AudioPlayer::file(fn);

    if(!ap) {
        std::cerr << "Error loading audio" << std::endl;
        return 1;
    }

    ap->play();

    char indic[] = { '|', '/', '-', '\\' };
    int i = 0;
    do {                                               // 5
//        std::cout << "Loop." << std::endl;
        CFRunLoopRunInMode (                           // 6
            kCFRunLoopDefaultMode,                     // 7
            0.25,                                      // 8
            false                                      // 9
        );

        std::cout << "\rPlaying.. " << indic[i];

        double d = ap->progress();
        double min = floor(d/60);
        double sec = floor(fmod(d,60));
        std::cout << "   " << min << ":" << sec;

        d = ap->duration();
        min = floor(d/60);
        sec = floor(fmod(d,60));
        std::cout << "   " << min << ":" << sec;

        std::cout << std::flush;

        if(ap->progress() > 5) {
            ap->seek(rand()/(float(RAND_MAX))*ap->duration());
        }

        i = (i+1)%4;
    } while (ap->isPlaying());



    delete ap;

#if 0


//    std::cout << "dataformat " << aqData.mDataFormat << std::endl;
    std::cout << "bufferbytesize " << aqData.bufferByteSize << std::endl;
    std::cout << "numpacketstoread " << aqData.mNumPacketsToRead << std::endl;
    std::cout << "maxpacketsz " << maxPacketSize << std::endl;
    std::cout << "df bpp " << aqData.mDataFormat.mBytesPerPacket << std::endl;
    std::cout << "df fpp " << aqData.mDataFormat.mFramesPerPacket << std::endl;



    unsigned int running =0;
    sz = 4;
        status = AudioFileGetProperty (                             // 9
            aqData.mAudioFile,                             // 10
             kAudioQueueProperty_IsRunning ,             // 11
            &running,                                   // 12
            &sz                                    // 13
        );

    std::cout << "Running: " << running << std::endl;




    running =0;
    sz = 4;
        status = AudioFileGetProperty (                             // 9
            aqData.mAudioFile,                             // 10
             kAudioQueueProperty_IsRunning ,             // 11
            &running,                                   // 12
            &sz                                    // 13
        );

    std::cout << "Running: " << running << std::endl;


    return 0;
    do {                                               // 5
//        std::cout << "Loop." << std::endl;
        CFRunLoopRunInMode (                           // 6
            kCFRunLoopDefaultMode,                     // 7
            0.25,                                      // 8
            false                                      // 9
        );
    } while (aqData.mIsRunning);

    CFRunLoopRunInMode (                               // 10
        kCFRunLoopDefaultMode,
        1,
//.........这里部分代码省略.........
开发者ID:jmoyers14,项目名称:csc344,代码行数:101,代码来源:main.cpp


注:本文中的AudioPlayer::progress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。