jplayer / jPlayer

jPlayer : HTML5 Audio & Video for jQuery
http://jplayer.org/
Other
4.6k stars 1.47k forks source link

Different audio formats in same jPlayer #136

Closed devsnd closed 11 years ago

devsnd commented 11 years ago

Hello, I'm working on a music streaming server based on jPlayer called CherryMusic, that allows people to stream their own music collection. Since those collections come with a variaty of different formats, I'm transcoding them automatically if jPlayer can not play them.

The program transcodes tracks to mp3 and ogg, that means that I have set "mp3, oga" as supplied argument. So if I have a playlist with mixed format tracks, I surely could transcode them all to a playable format, but I'd like to play the tracks without transcoding when possible. For example: Assuming HTML5 supports ogg and flash supports mp3; In this case there would be no need to transcode any music at all if the solution could be switched on the fly!

The problem is, that the supported formats are fixed after initialization. So depending on the track, I'd like to be able to reset the used solution based on the format. Can you give me any hints how to change the used solution without reinstantiating a new jPlayer instance for each track?

thank you for your great work on jPlayer

happyworm commented 11 years ago

If you do not care about which solution jPlayer uses, you can give one of the essential formats. In your case, the mp3 alone would be fine. Chrome would use HTML5, and Firefox would use Flash to play it.

One thing to consider is that within a year or so, Firefox and Opera are going to start supporting the codecs installed on the operating system. So Firefox will start playing mp3 in HTML5 within the next few updates.

If you are only playing audio media, then there is a trick that you can use to cause jPlayer to install both solutions on browsers such as Firefox and Opera. ie., Those that do not support mp3/m4a format natively in html5. That is to add the m4v format to the supplied option.

supplied:"mp3,oga,m4v"

Then never give the video m4v... But the by-product is that jPlayer has the Flash solution ready to play only mp3 formats and the html can play the oga if it can.

Hmm... Think I got sidetracked... This does not help you.

Just use mp3 only if encoding the media on the fly is a pain. http://www.jplayer.org/latest/developer-guide/#jPlayer-essential-formats

devsnd commented 11 years ago

Yes, this was exactly what I was looking for. I didn't know that the 2 solutions could be used at the same time (and that they would switch automatically). Thank you very much!