Google drive embed NO iframe

11,497

Solution 1

Do you mean like this:

<object width="420" height="315" data="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview">

<embed width="420" height="315" src="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview">

I have tested the code and it works.

Solution 2

It's possible but not officially supported.

After some study of the result generated by the iframe embed from Google Drive and the iframe from YouTube I've digged into the YouTube JS Player API and found out that it's possible using SWFObject embed

Here is the code that I use to add the player object:

function YT_createPlayer(divId, videoId) {

    var params = {
        allowScriptAccess: "always"
    };

    var atts = {
        id: videoId
    };

    //Build the player URL SIMILAR to the one specified by the YouTube JS Player API
    var videoURL = '';
    videoURL += 'https://video.google.com/get_player?wmode=opaque&ps=docs&partnerid=30'; //Basic URL to the Player
    videoURL += '&docid=' + videoId; //Specify the fileID ofthe file to show
    videoURL += '&enablejsapi=1'; //Enable Youtube Js API to interact with the video editor
    videoURL += '&playerapiid=' + videoId; //Give the video player the same name as the video for future reference
    videoURL += '&cc_load_policy=0'; //No caption on this video (not supported for Google Drive Videos)


    swfobject.embedSWF(videoURL,divId, widthVideo, heightVideo, "8", null, null, null, null);

}

You need to fetch the fileId from Google Drive some how (JS or server side, you can use a GAS Servlet if you want to host the site on Google Drive).

Most of the YouTube Player Parameters works, and events to control the playing status from JS are fired; so basically anything from the Youtube Documentation works.

Share:
11,497

Related videos on Youtube

ihtus
Author by

ihtus

Updated on June 04, 2022

Comments

  • ihtus
    ihtus almost 2 years

    Is there any way to embed google drive video without using iframes?

    Just like you can do with youtube video:

    <object width="320" height="180">
              <param name="movie" value="http://www.youtube.com/v/UHk6wFNDA5s&amp;showinfo=0">
              <param name="wmode" value="transparent">
              <embed src="http://www.youtube.com/v/UHk6wFNDA5s&amp;showinfo=0" type="application/x-shockwave-flash" wmode="transparent" width="320" height="180">
    </object>
    

    The suggested embed code from google docs (using iframe) is:

    <iframe src="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview" width="640" height="385"></iframe>
    
  • Ignatius Samuel Megis
    Ignatius Samuel Megis almost 7 years
    HI there, is that your script still work? I've been try that but its not work, can you give some example please? thanks ,Regards
  • smokybob
    smokybob almost 7 years
    Hi, the method does not work mostly because the SWF object uses Flash which is disabled on the various browsers. I don't think is now possible to avoid using Iframes, but I've never looked into it after summer 2016 when we moved the videos to Cloud Storage for various reasons (better performace, progressive caching, etc...)