Forums

window.addEventListener('deviceorientation', requestAnimationFrame(panVideo));

This works perfectly playing 360 degree videos if I call the html file whilst logged on, but not if I use flask )or even as a static html file while logged out) It still plays but doesn't orientate with movement of the smartphone

Not sure what you do. Could you describe it more?

I'm displaying a 360 degree video on a smartphone intended for a google cardboard style VR headset, so the video moves as the person moves their head. Thats what the event listener does I'm planning to control the playback speed via Bluetooth otherwise I'd just just the YouTube app. Work in progress...

<div id="player"></div>
<manifest
//permissions here
    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
        </application>
        <queries>
        <intent>
         <action android:name="com.google.android.youtube.api.service.START"/>
        </intent>
        </queries>
</manifest>
<script src="https://www.youtube.com/iframe_api"></script>

<script>
    let player;
    let panStarted = false;
    let n = 1;

    function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
            videoId: 'y-0KJyQRNpc',
            events: {
                'onStateChange': onPlayerStateChange
            }
        });
    }


    // Start animation when video starts playing.
    function onPlayerStateChange(event) {
        if (event.data == 1 && !panStarted) {
            requestAnimationFrame(panVideo);
            panStarted = true;
        }
    }

    function panVideo() {
              player.setPlaybackRate(Math.floor(Math.random() * 6));
                  requestAnimationFrame(panVideo);
    }
    window.addEventListener('deviceorientation', requestAnimationFrame(panVideo));

</script>

From what you're saying that could be the issue related to the static files mappings -- do you have full paths to your PythonAnywhere environment hardcoded in your web app? That would work when you're logged in and have an open session, but otherwise would not. See this help page for more details.