5

I'm working on Facebook Spark Studio for the first time.

I wanted to do a marker based AR, like I usually do with Vuforia.

I wanted to play a mp4 video by scanning the a marker.

I read the Facebook AR studio docs, where they are supporting png and jpg file formats only.

Ref: https://developers.facebook.com/docs/ar-studio/before-you-start/file-formats

Are there any playback controls for external video texture?

Can any one help me to play a video on scanning a tracker?

Subbu
  • 663
  • 1
  • 9
  • 20

2 Answers2

2

We had the same issue. The trick (or Facebook bug) is to set the url in the editor in the material with the link to your video. Then in your code do this:

const Scene = require('Scene');
const Animation = require('Animation');
const Materials = require('Materials');
const Textures = require('Textures');
const D = require('Diagnostics');
const Audio = require('Audio');

const animRoot = Scene.root.find('animRoot');
const planeTracker = Scene.root.find('planeTracker');
const targetMat = Materials.get('targetMat');
const externalText = Textures.get('externalAnimation');
const playbackController = Audio.getPlaybackController('playback_controller_model0');

planeTracker.confidence.eq('HIGH').onOn({fireOnInitialValue: true}).subscribe(function(e) {

    playbackController.play();

    externalText.url = '';

    externalText.url = 'https://urlToYourVideo.mp4';

    D.log('Tracking starts');
});

planeTracker.confidence.eq('HIGH').onOff({fireOnInitialValue: true}).subscribe(function(e) {

    playbackController.stop();

    externalText.url = '';

    D.log('Tracking stops');
});

Hope this helps!

Laurent
  • 108
  • 8
  • is it working? I followed external texture approach which I am applying to a plane as a material but sound is not coming. I used above solution on tap of plane event in javascript and changed the external texture url but still not able to hear the video sound. Any pointers guys.... – Akki619 Jan 26 '19 at 09:42
0

You can do that using an "External Texture" by linking a video texture that is hosted online.

  1. Create a material
  2. Under the material diffuse texture property choose "New External Texture"
  3. In the texture properties enter the URL for your video into the URL field

enter image description here enter image description here

To use a tracker, look at the documentation for the PlaneTracker object: https://developers.facebook.com/docs/ar-studio/docs/plane-tracker/

JackKalish
  • 1,555
  • 2
  • 15
  • 24
  • I appreciate your answer. I was using this procedure to apply a video to the plane marker. But the problem was that I couldn't able to here voice from the video. And the video is automatically playing after scanning the marker which I don't want. are there any controls that I can apply to the video texture to reset or to pause? – Subbu Oct 20 '18 at 00:01
  • 1
    External textures do not support audio, as far as I know, for now it is just video. It does not appear that there is a way to control the playback either, but I would try either setting the object visibility, or changing the external texture URL via script to trigger when playback occurs. – JackKalish Oct 23 '18 at 19:50
  • Yeah... I'm trying to add external texture url via script. But that's not happening. I dunno why. Basically I want to play a speech video. Is there any way to do that? Please help me with this – Subbu Oct 23 '18 at 19:56