Appearance
流媒体相关
只列出部分主要功能,其他功能及参数详细说明请参考官方文档https://www.npmjs.com/package/cordova-plugin-streaming-media
介绍
cordova-plugin-streaming-media 播放音、视频
主要功能
播放视频
示例
js
var videoUrl = STREAMING_VIDEO_URL;
window.plugins.streamingMedia.playVideo(videoUrl);
var options = {
successCallback: function () {
console.log("Video was closed without error.");
},
errorCallback: function (errMsg) {
console.log("Error! " + errMsg);
},
orientation: "landscape",
shouldAutoClose: true, // true(default)/false
controls: true, // true(default)/false. Used to hide controls on fullscreen
};
window.plugins.streamingMedia.playVideo(videoUrl, options);
播放音频
示例
js
var audioUrl = STREAMING_AUDIO_URL;
window.plugins.streamingMedia.playAudio(audioUrl);
var options = {
bgColor: "#FFFFFF",
bgImage: "<SWEET_BACKGROUND_IMAGE>",
bgImageScale: "fit", // other valid values: "stretch", "aspectStretch"
initFullscreen: false, // true is default. iOS only.
keepAwake: false, // prevents device from sleeping. true is default. Android only.
successCallback: function () {
console.log("Player closed without error.");
},
errorCallback: function (errMsg) {
console.log("Error! " + errMsg);
},
};
window.plugins.streamingMedia.playAudio(audioUrl, options);
// Stop current audio
window.plugins.streamingMedia.stopAudio();
// Pause current audio (iOS only)
window.plugins.streamingMedia.pauseAudio();
// Resume current audio (iOS only)
window.plugins.streamingMedia.resumeAudio();
详细说明网址
https://www.npmjs.com/package/cordova-plugin-streaming-media