所以我正在使用 Wistia 播放器 API 构建一个 Ionic / AngularJS 应用程序。我最终尝试过,一切都在浏览器测试模式下正常工作。但是当编译到iOs上时,它只是显示白屏。这是详细信息:
查看 - HTML 页面:
<!-- Wistia Embed -->
<div id="{{ 'wistia_' + mediaHashId }}" class="wistia_embed" style="width:398px;height:224px;" ng-if="mediaHashId"></div>
控制器:
$timeout(function() {
var wistiaEmbed = Wistia.embed($scope.mediaHashId, {
videoFoam: true,
playerColor: "3B97D3"
});
wistiaEmbed.bind("end", function () {
alert ("Video is finished");
});
}, 100);
所以它可以完美地加载到 Chrome 上。但是当我将它编译到 xcode 上并在我的手机上运行它时。它只是显示一个白屏(没有 JS 错误!)
第二个选项:iframe - 因为 iframe 在 iO 上加载正常(http://wistia.com/doc/player-api#using_iframes_and_the_player_api)。第二个选项是将 wistiaApi 附加到 iframe 上。但是代码不起作用。
查看 - HTML 页面:
<div class="video-container">
<iframe id="wistia_player" ng-src="{{ mediaHashId | wistiaEmbedUrl }}" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" width="640" height="360"></iframe>
</div>
控制器:
$timeout(function() {
var wistiaEmbed = document.getElementById("wistia_player").wistiaApi;
console.log (wistiaEmbed);
wistiaEmbed.bind("end", function () {
alert ("Video is finished");
});
}, 100);
wistiaEmbed 控制台记录一个未定义的。和错误日志:
TypeError: Cannot read property 'bind' of undefined
at lesson-detail-ctrl.js:46
at ionic.bundle.js:24922
at completeOutstandingRequest (ionic.bundle.js:13604)
at ionic.bundle.js:13984
很明显 .wistiaApi 不起作用......
我确实将它包含在我的 index.html 中:
我会喜欢这样的 AngularJS 库 https://github.com/brandly/angular-youtube-embed和 Wistia Player ......但没有运气......