Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can animated GIFs be shown on the Glass timeline?

Using the Mirror API, can animated GIF images be attached to the Glass timeline? If so, will they actually animate on Glass or present as a static image?

like image 727
rymo Avatar asked Feb 16 '23 10:02

rymo


2 Answers

Animated GIF images work both as attachment and as <img> tags in HTML.

like image 77
Alain Avatar answered Mar 25 '23 10:03

Alain


To answer the second question the gif animates. I tested with a timeline card like this:

{
  "kind": "mirror#timelineItem",
  "id": "6fd3c490-f751-40e3-8e1f-8b71494160fc",
  "created": "2013-05-28T20:05:23.589Z",
  "updated": "2013-05-28T20:05:23.589Z",
  "etag": "\"r3ghbVW9Rp1kDP4UexS05_pFx4E/jVAhcX1aYFm8-1tN5G5Fv6RSscQ\"",
  "html": "<article class=\"photo\">\n  <img src=\"http://media.idownloadblog.com/wp-content/uploads/2012/05/Sonic-Animated.gif\" width=\"100%\" height=\"100%\">\n  <div class=\"photo-overlay\"></div>\n  <section>\n    <p class=\"text-auto-size\">Spring Fling Fundraiser at Filoli</p>\n  </section>\n</article>\n",
  "notification": {
    "level": "DEFAULT"
  }
}

And the gif animates on Glass. It did take a moment to download displaying the card with a generic gray image icon with the text on top at first, but once the image showed up it definitely is animated and looping. If you go back to it later it still animates.

Update - It is possible to animate an attached GIF with new help from Jenny Murphy over at the issue tracker. If you include very basic HTML that references the attachment (eg ) it does work and animate. I have verified this with Glass using XE6.

This is the java code to do so:

            TimelineItem timelineItem = new TimelineItem();
        timelineItem.setText("");
        timelineItem.setNotification(new NotificationConfig()
                .setLevel("DEFAULT"));
        //add html with reference to attachment using index 0
        timelineItem.setHtml("<img src=\"attachment:0\">");
        // Attach animated GIF
        String contentType = req.getParameter("contentType");
        URL url = new URL(req.getParameter("imageUrl"));
        byte[] b = ByteStreams.toByteArray(url.openStream());
        InputStream animatedGifStream = url.openStream();
        MirrorClient.insertTimelineItem(credential, timelineItem,
                contentType, animatedGifStream);

A full working implementation of this is at: https://github.com/mscheel/mirror-quickstart-java

That is the starter project for Java with extra features to attach a video or now an animated gif by attachment.

like image 24
Mark Scheel Avatar answered Mar 25 '23 11:03

Mark Scheel