本文整理汇总了C++中AudioPlayer::isPlaying方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioPlayer::isPlaying方法的具体用法?C++ AudioPlayer::isPlaying怎么用?C++ AudioPlayer::isPlaying使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioPlayer
的用法示例。
在下文中一共展示了AudioPlayer::isPlaying方法的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;
}
示例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,
//.........这里部分代码省略.........