ちょっと、またAS3でコンテンツ作ろうとして、mp3ファイルをEmbedしようとしたんだが、何故かこんなエラーが出てきた。原因をいろいろと調べたところ、サンプリングレートが悪い説とかいろいろ出てきた。で、再サンプリングしてみても状況が変わらない。
で、色々調べているうちに、真の原因がわかったのでメモしておく。
- SoundEmbed.as(17): col: 3: Error: unsupported sampling rate (0Hz)
- [Embed(source = "../sample.mp3")]private const SampleSound:Class;
- ^
- SoundEmbed.as(17): col: 3: Error: Unable to transcode ../sample.mp3.
ということで作ったコードはこれ。これだけでコンパイルすら出来ない所が凄い。しかも、原因は読み込んでるMP3ファイル側。
原因だが、「アルバムのタイトル」に、日本語が入っているとダメだった。理由は不明だが。ということで、Windowsの「プロパティ」から、アルバムのタイトルを半角文字だけにしたところ動作した。よしよし。
ちなみに、エラーメッセージの「(0Hz)」のところだが、アルバムのタイトルに入れる日本語によって変わった。「タロウ」だと0だったが、「太郎」だと(32000Hz)だった。
- package
- {
- import flash.display.*;
- import flash.media.Sound;
- /**
- * ...
- * @author tarotarorg
- */
- public class SoundEmbed extends Sprite
- {
- [Embed(source = "../sample.mp3")]private const SampleSound:Class;
- public function SoundEmbed()
- {
- var snd:Sound = new SampleSound() as Sound;
- snd.play();
- }
- }
- }