Start a new topic

AR.context.startVideoPlayer not playing video

AR.context.startVideoPlayer not playing video

i am making few changes in imagerecognition.js of 1_Image$Recognition_1_Image$On$Target 

when i use

var imgOne = new AR.context.openInBrowser("");

i works fine

but when i write 

var imgOne = new AR.context.startVideoPlayer("");


i ge message cannot play video 


why so ??

startVideoPlayer requires a direct link to a video file. E.g. a mp4 file. Linking to a youtube webpage does not work.

I suggest uploading the video file to a webserver instead of youtube.

problem is that when i play video form assest folder i get error video can not be played why so ??

below is code i am usig:

var vidonetopay = new AR.context.startVideoPlayer("assets/a.mp4");

which platform are you testing this on. Have you tried using a full asset url?

i am using android

function showHorseVideo()


var vidonetopay = new AR.context.startVideoPlayer("assets/a.mp4");


var pageOne = new AR.Trackable2DObject(this.tracker, "rsz_1christmas_gettyimages", {

drawables: {

cam: htmlDrawable

}, onEnterFieldOfVision: showHorseVideo



below is code i am using.

I have placed video in:

1_Image$Recognition_1_Image$On$Target >> assets >> a.mp4

am i missing something ??


can i also play video from SD Card ??

Can you try using the method below to convert the relative url to an absolute one?

function relativeToAbsolute(url) {
if (/^(+:)?\/\//i.test(url)) {
// URL contains protocol and can be considered absolute
return url;

// get protocol
var protocol = document.baseURI.substring(0,
document.baseURI.indexOf('/') + 2);
var uri = document.baseURI.substring(document.baseURI.indexOf('/') + 2);

// remove trailing file (edge case, this is just a domain e.g.
uri = uri.substring(0, uri.lastIndexOf('/') + 1);

var baseUrl = protocol + uri;
if (baseUrl !== '/')
baseUrl += '/';

if (url === '/') {
// url references root
baseUrl = baseUrl.substring(0, baseUrl.indexOf('/', baseUrl
.indexOf('//') + 2));

return baseUrl + url;


still not working check attached imagerecognition.js if missing anything ??

okay, I quickly scanned your code and it looks good. Can you try opening the same file in the android browser to see if it is able to play the video (could be a codec problem)?

Additionally can you send us a download link to the file so we can try it out on our end?

For further testing it would be great to know the exact android version you tried this on? Have you tried it on different devices?


yeah, when i play it from url it works

you can check with any video

may try beow link


Have to tried to play and video from assest folder of apk ?? 


Hi There!


As it is right now the AR.context.startVideoPlayer method is aimed at displaying videos from external URLs that reside on an external webserver. For local resources as in your case in the assets folder this might cause some problems.

So if that constitutes a possibility for you, the fastest way for you would be to load your video file on a webserver and use that as input for the AR.context.startVideoPlayer method.


Another maybe more flexible solution would be to write your own VideoPlayer activity in java and design it upon your needs. As this activity only consists of a few components this task should not be to lengthy. The ApiDemos project that ships with your Android SDK (Path: YOUR_ANDROID_SDK_FOLDER/sdk/samples/API_LEVEL/ApiDemos) should give you a very good starting point to quickly complete that task. Specificly the and classes should be very helpful. 


This activity can then be triggered via the ArchitectUrlListener class of the Wikitude SDK. With that listener you can react to events that happen in Javascript in your native Android activity (More detailed information can be found in our Android Wikitude SDK documentation). 

As an example, in your ARchitect world you could then write 

e.g.: document.location =  architectsdk://openvideo?url=LOCAL_PATH_TO_YOUR_VIDEO

which then could be parsed in your native activity in ArchitectUrlListener's urlWasInvoked callback, in order to then start your VideoPlayer activity.


Hope that helps,


onEnterFieldOfVision : function showVideo()




var vidonetopay = new AR.context.startVideoPlayer(



Login or Signup to post a comment