I'm trying to publish my Construct 2 game, and after exporting to Intel XDK the game wont start using Simulate or Test tabs. Error: "failed to load resource: the server responded with a status of 401 (Unauthorized) ... http://localhost:65129/Vinheta.webm". This file is a video that is supposed to run at the start of the game. The strange thing is that it runs without any errors on Debug tab...
So i decided to build the app anyway hoping it could work on my device...but without success.
If i change the code on Construct 2 to skip the video, then the app runs perfectly.
I've also tried to build with phonegap and for my surprise the video play just fine, no errors at all... but the performance is ridiculous compared to Intel XDK.
Ended up with this video playback problem. Already thought that i may use some specific plugin for doing it, but if this is a need, then why it works on phonegap and in Debug tab?
May someone help me with this?
I suspect you have to configure your whitelist settings to get it to work properly in the built app. The whitelist settings in the Debug tab are "wide open" to make sure things work (as is the Test tab). Not sure why it didn't work in the Test tab, but that's probably why it's not working in the built app. See this doc page for help with whitelists > https://software.intel.com/en-us/xdk/docs/using-cordova-whitelist-rules-with-intel-xdk <
Thanks for the reply and for the link! As i'm not experienced with coding (C2 user), i'm not sure what to look for. There is a lot of whitelist options to mess with, and as i can see, the most of them are already setup on build settings tab on Intel XDK. The error appear when trying to load a file from an http://localhost:.../myVideo
I'm not sure if it is a network request, an allow-navigation or an intent...
Can you tell me which one do you think that applies to this case?
Thank you very much!
You cannot do a "localhost" load in a Cordova app, there is no server present to respond to the request. Changing it to a file:// URL might be sufficient, but a better solution would be to either use an existing HTML5 audio/video API or a Cordova plugin that handles audio/video playback directly from a file.
The details are beyond the support we are able to provide in this forum, I suggest you look for solutions under the PhoneGap and Cordova tags in Stack Overflow. The XDK builds a standard Cordova (aka PhoneGap) app, those solutions will work here.
Thanks again! I'm not trying to do a "localhost" on my app, as i'm not sure what to do. I'm just trying to follow the error and maybe find what is going wrong. In the simulate tab, the error is followed by an adress "http://localhost:(some number)/Vinheta.webm" so i suppose that i have to authorize the access to this file.
I also read something about absolute and relative paths could give this kind of error, but i'm not sure if i got it right. If so, i need to find the absolute path for it, but then it occurs me that after building the app, this file should be somewhere else inside the mobile device and maybe the absolute path wont work...just trying all possible ways that i can figure out on my own.
How can i change it to a file://URL?
Do i need a plugin for playing video files?
I read that some browsers could not start playing a video without some kind of user input, or trigger. Do you know something about it?
Thank you very much!
After re-reading your original post, it still sounds like the whitelist is the problem. See this page > https://software.intel.com/en-us/xdk/articles/cordova-whitelisting-with-intel-xdk-for-ajax-and-launc... < and please setup your whitelist and CSP rule per the recommendations on that page. In particular, try putting the following in the whitelist field for Android:
And the following for iOS:
And try adding '*' in the Navigation field if those don't work.
I really appreciated your help, thanks!!! I'm actually publishing for Android, but this information will be very usefull indeed. My whitelist configuration was exactly as in the picture you've posted. I also tried to add the * to the navigation field, but it results the same.
The image bellow has some information on the error i'm facing...
There is one weird things in this log: the file type is showing as text/plain ?! I've double checked that the file in my www project folder is working nice.
Thank you very much!
The problem is solved. This happens because of some browsers can not play a video without a user input. After adding a button triggering the video the problem was gone.
Here is what was posted on Scirra website:
On Safari for iOS and Chrome for Android, video playback cannot begin unless triggered by a user input event. The Play action will work in a user input trigger like On touch start, but if done outside of that it cannot play right away. To work around this the video plugin will wait until the next touch event to start playing the video. This also applies to autoplaying videos: it will not start until the first touch.
I would like to thank you anyway, for your time and effort helping me!