Cordova Media Player错误

时间:2017-12-04 19:10:16

标签: android cordova

我正在尝试在cordova应用中播放来自网络服务器的视频。我尝试了多个插件,但目前没有一个插件适用于我。

https://www.npmjs.com/package/cordova-plugin-video-player

https://github.com/nchutchind/cordova-plugin-streaming-media

但他们两个都不适合我。

这是代码。

function playvideos(){

 VideoPlayer.play(
    "https://www.teztertb.xyz/video/T3_1512322360.mp4",
    {
        volume: 0.5,
        scalingMode: VideoPlayer.SCALING_MODE.SCALE_TO_FIT_WITH_CROPPING
    },
    function () {
        console.log("video completed");
    },
    function (err) {
        console.log(err);
    }
);
}

我也尝试了第二个插件的另一个代码。

function playvideo() {

   var videoUrl="https://www.mysite.xyz/video/T3_1512322360.mp4";
          console.log('local url      :'+videoUrl);
          var options = {
            successCallback: function() {
              console.log("Video was closed without error.");
            },
            errorCallback: function(errMsg) {
              console.log("Error! " + errMsg);
            }
          };
          try
          {
           window.plugins.streamingMedia.playVideo(videoUrl,options);
         }
         catch(Error)
         {
             console.log("error from server or local"+Error);
         }

      }

我在config.xml中做了一些更改,如下所示。

 <allow-intent href="*" />
    <access origin="*" />
    <allow-navigation href="http://*/*" />
    <allow-navigation href="https://*/*" />
    <allow-navigation href="*" />
    <allow-navigation href="data:*" />

并在index.html文件中添加了代码。

<meta http-equiv="Content-Security-Policy" content="style-src 'self' 'unsafe-inline'; media-src *; connect-src *">

我不知道接下来要做什么,因为我一直都会收到一些错误。我也试过youtube视频,但这也没有播放。

我收到以下错误。

cordova媒体播放器错误:未知(1) - 1005

cordova媒体播放器错误:未知(1) - 1004

0 个答案:

没有答案
相关问题