Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
@sygnas/audio-src
Advanced tools
Readme
Check user environment and set HTML5 Audio from HDS / HLS / MSE
ユーザー環境をチェックして、HDS / HLS / MSE のソースを HTML5 Audio にセットする。
HTML5 の new Audio()
にオーディオソースをセットするだけのモジュールです。
再生コントロールはしません。
MSE形式(MPEG-DASH)を使う場合は dash.js が必要。
npm install --save @sygnas/audio-src
import AudioSrc from '@sygnas/audio-src';
const audio_src = new AudioSrc();
audio_src.set_src("hoge.mp3", ardio_src.TYPE_FILE);
http://stm.foo.bar/abcd1234.mp4/manifest.f4m
というプレイリストにアクセスしてストリーミングする場合。
if(audio_src.check_support()) {
audio_src.set_src(
"stm.foo.bar/abcd1234.mp4",
ardio_src.TYPE_HDS
);
}
下記3種類が用意されていて、環境に合わせたタイプを自動的に選択する場合。
HDS形式:http://stm.foo.bar/abcd1234.mp4/manifest.f4m
HLS形式:http://stm.foo.bar/abcd1234.mp4/playlist.m3u8
MSE形式:http://stm.foo.bar/abcd1234.mp4/manifest.mpd
if(audio_src.check_support()) {
audio_src.set_src("stm.foo.bar/abcd1234.mp4");
}
Audio の再生制御はしないので、他のライブラリなどで個々に実装する必要がある。
audio_arc.audio.load();
audio_arc.audio.play();
new SetAudio({
hds: {
protcol: 'http://',
playlist: '/hoge.f4m',
}
});
パラメータ | デフォルト | 備考 |
---|---|---|
hds | {protcol: 'http://', playlist: '/manifest.f4m'} | HDS形式で使用するプロトコルと、プレイリスト |
hls | {protcol: 'http://', playlist: '/playlist.m3u8'} | HLS形式で使用するプロトコルと、プレイリスト |
mse | {protcol: 'http://', playlist: '/manifest.mpd', autoplay: false} | MSE形式で使用するプロトコルと、プレイリスト、自動再生するか |
HTML5 Audio。
dash.js のインスタンス。
HDSを再生できるか。
HLSを再生できるか。
MedisSourceExtensionに対応しているか。
ソースとして設定されたタイプ。TYPE_HDS ... TYPE_FILE などが入る。
サポートする環境をチェック。非ストリーミングの場合は関係ない。
戻り値:{Boolean} true: チェック完了 / false: 対象外環境
オーディオソースを渡してHTML5 Audioにセットする
引数 | 型 | 備考 |
---|---|---|
url | String | mp3/ogg など非ストリーミングの場合はファイルのURL |
type | String | ストリーミング、非ストリーミングのタイプを指定する |
ストリーミングの場合は http://{この部分}//manifest.f4m をベースURLとして渡す。
非ストリーミングの場合は TYPE_FILE
を必ず指定。
無指定の場合は環境に合わせたタイプが使用される。
引数 | 備考 |
---|---|
{instance}.TYPE_FILE | 非ストリーミング |
{instance}.TYPE_HLS | HLS形式 |
{instance}.TYPE_HDS | HDS形式 |
{instance}.TYPE_MSE | MSE形式 |
if(audio_src.check_support()) {
audio_src.set_src(
"stm.foo.bar/abcd1234.mp4",
ardio_src.TYPE_HDS
);
}
MIT
FAQs
Check user environment and set HTML5 Audio from HDS / HLS / dash.js
We found that @sygnas/audio-src demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).