سؤال

عندما أحاول تشغيل ملف الصوت "Windows Cruction Stop.wav" أحصل على الاستثناء التالي: exec {"Sound API only supports playing PCM wave files."} System.Exception {System.InvalidOperationException}

أنا أفهم ماهية PCM ، أنا فقط لا أعرف كيف: 1) قم بتشغيل ملف الصوت ، 2) تحديد مسبقًا أنه ليس PCM ولن يتم تشغيله ، وحظر الملف من الاختيار.

هنا هو الرمز الذي أستخدمه:

SoundPlayer player = new SoundPlayer();
player.SoundLocation = FileNameTextBox.Text;

try
{
    player.Play();
}
catch (Exception exec)
{
    MessageBox.Show("Sound could not be played: " + exec.ToString());
}
هل كانت مفيدة؟

المحلول

يمكن ترميز ملفات الموجة بشكل مختلف (حتى مع برنامج ترميز GSM) ، لذلك فقط قم بفحص الترميز المستخدم لتخطي واحد معين. فقط تحقق من البتات Audioformat.

https://ccrma.stanford.edu/courses/422/projects/waveformat/

نصائح أخرى

يجب عليك استخدام هذا المشغل الرمز الذي لديك هو نظام Damager Microsoft ،

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top