When making calls to the Instagram API to get a list of media, Skybrud.Social will parse these into instances of InstagramMedia (which is actually an abstract class).
Depending on whether a given media is either an image or a video, the actual class will be either InstagramImage or InstagramVideo correspondingly (since both of these classes inherit from the abstract InstagramMedia class).
Here is a small example on how to use and check against the type of media:
@using System.Web.Mvc.Html
@using Skybrud.Social.Instagram
@using Skybrud.Social.Instagram.Objects
@using Skybrud.Social.Instagram.Responses
@inherits System.Web.Mvc.WebViewPage
@{
InstagramService service = InstagramService.CreateFromClientId("client id");
InstagramRecentMediaResponse response = service.Tags.GetRecentMedia("umbraco");
foreach (InstagramMedia media in response.Body.Data) {
InstagramImage image = media as InstagramImage;
InstagramVideo video = media as InstagramVideo;
if (image != null) {
<div style="margin: 20px auto; width: @(image.Images.StandardResolution.Width)px">
<img src="@image.Standard" alt="" />
</div>
} else if (video != null) {
InstagramMediaSummary size = video.Videos.StandardResolution;
<div style="margin: 20px auto; width: @(size.Width)px;">
<video style="width: @(size.Width)px; height: @(size.Height)px" controls>
<source src="@size.Url" type="video/mp4" />
</video>
</div>
}
}
}
Instagram video URL
How do I access the video URL for instagram videos?
Using
@media.Standard
only returns the standard thumbnail for both images and videos - I am looking for the URL to the .mp4 file.Hi Søren,
When making calls to the Instagram API to get a list of media, Skybrud.Social will parse these into instances of
InstagramMedia
(which is actually an abstract class).Depending on whether a given media is either an image or a video, the actual class will be either
InstagramImage
orInstagramVideo
correspondingly (since both of these classes inherit from the abstractInstagramMedia
class).Here is a small example on how to use and check against the type of media:
Hope this answers your question ;)
Thank you Anders! That did the trick!
is working on a reply...