How to play binary MP3 stream with jQuery/Javascript?

前端 未结 5 1153
独厮守ぢ
独厮守ぢ 2021-01-14 00:01

I\'m getting a pure binary MP3 stream from an ajax call. No headers, nothing. Just straight MP3 bits. (Actually is that really even a stream at all?)

I\'d like to b

相关标签:
5条回答
  • 2021-01-14 00:40

    as indeed mentioned, you'll need a mp3 playing plugin, flash being the most widely available. The JMP3 jquery plugin makes that task easier for you. It does rely on a flash file for the sound processing.

    0 讨论(0)
  • 2021-01-14 00:48

    If you're only targeting very modern browsers, you could make use of data URL:s, and just write an object element to your HTML, and link to that data URL. Note: I havn't tried this.

    0 讨论(0)
  • 2021-01-14 00:53

    You might want to look at SoundManager 2: Javascript Sound for the Web

    Its an open-source BSD licensed JavaScript script for dealing with sound.

    It automatically hooks into HTML5 or Flash to produce the sound, depending on what is available.

    0 讨论(0)
  • 2021-01-14 00:58

    You cant play music with pure javascript. you will need to get that stream and pass it to a flash player.

    try JW flash player, though i am not sure if it can handle the type of stream you are talking about. you will have to do some research about what it can handle

    0 讨论(0)
  • 2021-01-14 01:00

    I have done this using data uris and there is the browser compatibility issue, there is the problem of url length (basically > about 30,000 characters won't support IE) and there is also the problem of the browser taking forever to decode the base64 value (the buffering is also extermely slow).

    With current web technology, I would say your best bet is to write the data to a temporary file on your server and then have something like Dewplayer load the temporary file and play it.

    0 讨论(0)
提交回复
热议问题