Tejas Manohar
Tejas Manohar

Reputation: 974

NodeJS HTML5 Audio Player MPEG File

We're receiving a direct link to a MPEG Audio file from a certain web streaming API and need to present it in HTML5 audio player. This isn't truly an MP3 with MPEG codec, but an MPEG video format with pure audio only.

Is there a workaround to get an MPEG into an HTML5 audio player? Or to put it in an HTML5 video player and take the styles from our custom HTML5 audio player and apply it to that (we need a way to hide the video container)?

Upvotes: 0

Views: 1078

Answers (1)

Yanick Rochon
Yanick Rochon

Reputation: 53616

If your audio player is totally custom (i.e. pure HTML /w JS, and reacts to <AUDIO> element's events), then you can simply create an adapter to also react to a <VIDEO> element that you can simply put offscreen. See the w3.org site for more information on video events and other API.

Note : I would give more precision on how to, unfortunately the qeustion is quite vague on the actual current implementation.

Update

Well, there are various HTML audio players out there. For Bootstrap, for example. Or jPlayer is another. Just Google HTML5 audio player for some more.

To put the video player offscreen, just style your element like

<video style="position:absolute; left:-99999px;">

That is, of course, if you brew your own player (not that hard, actually).

You may also take a look at an actual video player that can play audio sources, too. :)

Note: for video.js, follow this issue for audio support.

Upvotes: 1

Related Questions