<input id="ohw05"></input>
  • <table id="ohw05"><menu id="ohw05"></menu></table>
  • <var id="ohw05"></var>
  • <code id="ohw05"><cite id="ohw05"></cite></code>
    <label id="ohw05"></label>
    <var id="ohw05"></var>
  • c++(qt)播放wav文件的四種方式

      //方法一(要符合RIFF規范)
    1     QSound::play("E:/Projects/報警聲1-1.wav");
      //方法二(要符合RIFF規范)
    1     QSoundEffect in_effect;
    2     in_effect.setSource(QUrl::fromLocalFile("E:/Projects/報警聲1-1.wav"));
    3     in_effect.setLoopCount(QSoundEffect::Infinite);
    4     in_effect.setVolume(0.25f);    
    5     in_effect.play();
      //方法三(要符合RIFF規范)
     1     QFile in_wavFile;
     2     in_wavFile.setFileName("E:/Projects/報警聲2-1.wav");
     3     in_wavFile.open(QIODevice::ReadOnly);
     4     QAudioFormatin_audioFormat;
     5     in_audioFormat.setSampleRate(44100);
     6     in_audioFormat.setChannelCount(2);
     7     in_audioFormat.setSampleSize(16);
     8     in_audioFormat.setCodec("audio/pcm");
     9     in_audioFormat.setByteOrder(QAudioFormat::LittleEndian);
    10     in_audioFormat.setSampleType(QAudioFormat::UnSignedInt);
    11     QAudioOutput*in_audio=newQAudioOutput(in_audioFormat,0);
    12     in_audio->start(&in_wavFile);
      //方法四(限MP3格式編碼的wav文件)
    1     QMediaPlayer *in_player = new QMediaPlayer;
    2     in_player->setMedia(QUrl::fromLocalFile("E:/Projects/報警聲2-1.wav"));
    3     in_player->setVolume(50);
    4     in_player->play();
       

    posted @ 2021-09-23 17:26  李濤賢賢  閱讀(450)  評論(0編輯  收藏  舉報
    国产美女a做受大片观看