Play movie based on Observable

Back to How-to Discussions

Hi,

Since the upgrade to 1.3 my splash movie doesn't start anymore. I'm trying to play a movie on the splash page when Observable {playVideo} is true. When this is true I only see the beginning of the movie so it doesn't play but it's visible.

        <Video ux:Name="splashLogo" Layer="Background" File="../../assets/splash.mp4" IsLooping="true" AutoPlay="false" Visibility="Hidden">
            <WhileCompleted>
                <JavaScript>
                    router.goto("home");
                </JavaScript> 
            </WhileCompleted>
        </Video>


        <WhileTrue Value="{playVideo}">
            <Change Target="splashLogo.Visibility" Value="Visible" />
            <Play Target="splashLogo" Delay="0.2" />
        </WhileTrue>    
        <WhileFalse Value="{playVideo}">  
            <Change Target="splashLogo.Visibility" Value="Hidden" />
            <Stop Target="splashLogo" />
        </WhileFalse>

Liam,

The movie plays with AutoPlay="true" but with Javascript I do a check on startup if the movie should play or not (based on last visit) and if it shouldn't play I'll still hear the first 1-2 seconds of the movie just before going to the main page. See javascript below.

var Observable  = require("FuseJS/Observable");
var Storage 	= require('FuseJS/Storage');
var playVideo 	= Observable(false);

var obj;
Storage.read("settings.json").then(function(content) {
	obj = JSON.parse(content);
	obj.last_visit = Date.now();
	if(minutes > 5) {
		playVideo.value = true;			
		obj.last_splashscreen = Date.now();
		Storage.write("settings.json", JSON.stringify(obj));
	} else {
		playVideo.value = false;			
		Storage.write("settings.json", JSON.stringify(obj));
		router.goto("home");
	}
}, function(error) {
	obj = {last_visit: Date.now(), last_splashscreen: Date.now()};
	Storage.write("settings.json", JSON.stringify(obj));
	playVideo.value = true;
});

module.exports = {
	playVideo	: playVideo
};
Post Stats
  • 2
    replies
  • 131
    views
  • 2
    users