Play Vimeo video in Android , video url containing iframe

前端 未结 2 1439
庸人自扰
庸人自扰 2021-01-16 06:59

Hello i am working on android application in which i want to play vimeo videos , i am getting response from Api in json and playing video using webview and it is playing goo

相关标签:
2条回答
  • 2021-01-16 07:10
    mViewHolder.webView.getSettings().setJavaScriptEnabled(true);
    String yourData = "<div id='made-in-ny'></div>\n" +
                "\n" +
                "<script src='https://player.vimeo.com/api/player.js'></script>\n" +
                "<script>\n" +
                "    var options = {\n" +
                "        id: 59777392,\n" +
                "        width: 540,\n" +
                "        loop: true\n" +
                "    };\n" +
                "\n" +
                "    var player = new Vimeo.Player('made-in-ny', options);\n" +
                "\n" +
                "    player.setVolume(0);\n" +
                "\n" +
                "    player.on('play', function() {\n" +
                "        console.log('played the video!');\n" +
                "    });\n" +
                "</script>";
    mViewHolder.webView.loadData(yourData, "text/html; charset=utf-8", "UTF-8");
    

    change id and width. it is working.

    0 讨论(0)
  • 2021-01-16 07:27

    use style in html,

    String url = "<iframe src=\"" + videoUrl + "\" style=\"border: 0; width: 100%; height: 95%; padding:0px; margin:0px\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
    
    0 讨论(0)
提交回复
热议问题