Use a different parameter from json file on mobile and tablets

55 views Asked by At

I'm using Pannellum.org panorama player for a project, I'm loading the data to the player.htm file from a json file which looks something like this for each scene:

"default": {
    "firstScene": "one"
},

"scenes": {
    "one": {
        "title": "Mason Circle",
        "hfov": 110,
        "pitch": -3,
        "yaw": 117,
        "type": "equirectangular",
        "panorama": "/images/from-tree.jpg"
        }

There are multiple scenes which are fetched from this json file in the same directory as the player.htm file. I want to add some JS in the player.htm that uses an alternative path for "panorama" on mobile and tablet.

So I will set a second parameter in the json file called "panorama2" and if the device is mobile it will use this path for the original "panorama" parameter instead of the one that is set.

Is there a clean way of doing this with JavaScript for each scene?

0

There are 0 answers