Jump to:

23552 Posts in 19349 Topics by 2891 members

General Questions

SilverStripe Forums » General Questions » Embed problem!

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 3667 Views
  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    ok,
    I've tried to put the <embed> code directly in the Page.ss and when i loaded the page in the browser, it did the same thing.
    it removed it.

    <div id="unityPlayer" style="width: 720px; height: 450px; visibility: visible; ">
    <embed type="application/vnd.unity" style="display: block; width: 100%; height: 100%; " width="720" height="450" firstframecallback="unityObject.firstFrameCallback();" src="http://localhost:8888/SilverStripe-v2.4.5/assets/Uploads/MazePuzzle.unity3d">
    </embed>
    </div>

    When i inspect the code that the browser shows using Chrome's dev tools, this whole portion is removed...

  • martimiz
    Avatar
    Forum Moderator
    1091 Posts

    Re: Embed problem! Link to this post

    Ok, so I don't have the game and I have no idea what it looks like, but I had no problems installing it in SilverStripe anyway

    On a clean install, with no other javascript files loaded, in your Page_Controller:

    function init() {

       parent::init();

       Requirements::javascript('http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js');

       Requirements::customScript(<<<JS
          //gets the unityPlayer div and replaces the content with an embed tag which is the web player made by Unity (it works outside of SS.)
          function GetUnity() {
             if (typeof unityObject != "undefined") {
                return unityObject.getObjectById("unityPlayer");
             }
             return null;
          }
          //sets the parameters of the web player
          if (typeof unityObject != "undefined") {
             unityObject.embedUnity("unityPlayer", "MazePuzzle.unity3d", 720, 450);
          }
    JS
       );
    }

    (make sure there's no whitespace before the closing 'JS' !!!)

    in your template somewhere:

    <div id="unityPlayer">
    <div class="missing">
    <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
    <img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
    </a>
    </div>
    </div>

    Do a ?flush=1

    Now in my html (firebug) I see the div tag replaced:

    <div style="width: 720px; height: 450px; visibility: visible;" id="unityPlayer"><embed src="MazePuzzle.unity3d" firstframecallback="unityObject.firstFrameCallback();" style="display: block; width: 100%; height: 100%;" type="application/vnd.unity" width="720" height="450"></div>

    One more tip: make sure your html validates - maybe some forgotten closing </div> might cause the problem...

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    Hey, i've tried adding the init function you described in my page's controller, but now i can't even access the page. Its giving me the error that the "website might be down for maintenance or configured incorrectly", when i remove that part of the code, works right back.

    I've attached both the PHP file as well as the SS file.

    Attached Files
  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    And if you notice, that error that SS generates you is due to the fact that the <embed> tag is not properly closed by the unity plugin.

  • martimiz
    Avatar
    Forum Moderator
    1091 Posts

    Re: Embed problem! Link to this post

    For now, I narrowed it down to your Page header - so it's not SilverStripe after all :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" >

    Removing the first line will at least make it work:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" >

    One more thing: php started complaining about a unexpected t_sl error - due to the fact that there are extra whitespaces following <<<JS in your Page.php (removing them will get rid of the error - if you have it, that is...

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    thanks i was blind to that first line thing!
    and thanks for the whitespace info, it would've taken me forever to figure it out

    now i just need to figure how to get rid of the:
    GET http://localhost:8888/SilverStripe-v2.4.5/assets/Uploads/MazePuzzle.unity3d 403 (Forbidden)

    I found how to allow the file to be uploaded through the cms, but apparently its not enough to allow it
    to be accessed by the website.

    anyways, thanks for the great help!

  • martimiz
    Avatar
    Forum Moderator
    1091 Posts

    Re: Embed problem! Link to this post

    if it's not a rights issue, then did you add the file extension to the list in web.config file in the /assets/ directory? I read that SilverStripe restricts access to files that are not represented there(haven't tested)

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    Nop, tried it, didn't help.

    I'm able to "upload" it but when i come to access it (from the embed tag) it finds the file, but i get a 403 error in my javascript console.
    the error:
    GET http://localhost:8888/SilverStripe-v2.4.5/assets/Uploads/MazePuzzle.unity3d 403 (Forbidden)

    i've tried both a regular flush & a /dev/build just in case, but i still get the error

    3667 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.