{"id":2879,"date":"2023-02-18T13:58:00","date_gmt":"2023-02-18T12:58:00","guid":{"rendered":"https:\/\/www.itidea.nl\/?p=2879"},"modified":"2023-04-21T14:03:41","modified_gmt":"2023-04-21T12:03:41","slug":"creating-seamless-video-galleries-with-new-stream-and-sharepoint-components","status":"publish","type":"post","link":"https:\/\/www.itidea.nl\/index.php\/creating-seamless-video-galleries-with-new-stream-and-sharepoint-components\/","title":{"rendered":"Creating seamless Video Galleries with New Stream and SharePoint components"},"content":{"rendered":"\n<p>With the New Stream feature video content can be saved in a document library without the need for a dedicated portal like Classic Stream.<br>To reference a video on a SharePoint page the FileViewer component can be used.<\/p>\n\n\n\n<p>A custom video component displays videos from pages of a specific type as a beautiful video gallery, removing all other page content for a seamless viewing experience.<br>To accomplish this pages have to be loaded and per page the video has to be found by finding FileViewer components.<br>After the video component is found, the properties of the webpart have to be inspected to find the link to the video.<\/p>\n\n\n\n<p>When the video is stored in a OneDrive, accessing the video can be accomplished by using the &#8216;link&#8217; property. Use this link in for example an iframe and the video will open in the New Stream environment for a high-quality viewing experience.<\/p>\n\n\n\n<p>For videos stored in a document library the &#8216;link&#8217; property isn&#8217;t present, but a &#8216;file&#8217; property provides direct access to the video content. While you won&#8217;t get the benefits of the New Stream environment, you&#8217;ll still be able to view and play the video content with ease.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-Component-properties-content-stored-in-library-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"578\" height=\"395\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-Component-properties-content-stored-in-library-1.png\" alt=\"\" class=\"wp-image-2866\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-Component-properties-content-stored-in-library-1.png 578w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-Component-properties-content-stored-in-library-1-300x205.png 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-No-Stream-environment-library.png\"><img loading=\"lazy\" decoding=\"async\" width=\"704\" height=\"580\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-No-Stream-environment-library.png\" alt=\"\" class=\"wp-image-2867\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-No-Stream-environment-library.png 704w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-No-Stream-environment-library-300x247.png 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/a><figcaption class=\"wp-element-caption\">Video without New Stream environment<\/figcaption><\/figure>\n\n\n\n<p>To open video content in New Stream environment, simply visit:<br>[url\/_layouts\/15\/stream.aspx?id=[relative path to the video: \/sites\/sitename\/library\/video.mp4]<br>If the video is stored in a site other than the root, make sure to include the appropriate structure in the URL.<\/p>\n\n\n\n<p>Suppose the video is stored in \/sites\/dev-site in a library called MyLibrary the url must be like:<br>https:\/\/itidea.sharepoint.com\/sites\/dev-site\/_layouts\/15\/stream.aspx?id=\/sites\/dev-site\/MyLibrary\/<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-New-Stream-environment-library.png\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"583\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-New-Stream-environment-library.png\" alt=\"\" class=\"wp-image-2868\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-New-Stream-environment-library.png 703w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2023\/02\/Aggregate-videos-View-video-in-New-Stream-environment-library-300x249.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/a><figcaption class=\"wp-element-caption\">Video with New Stream environment<\/figcaption><\/figure>\n\n\n\n<p>Since the video content stored in OneDrive has the &#8216;file&#8217; property as well, this same property can be used at all situations.<br>Simplified code shows the steps:<br>First find the appropriate control<br>Check if it&#8217;s video content<br>Format the url so the content opens in the New Stream environment<br>Use the url is eg an iframe<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nlet result = page.findControl((c) =&gt; {\n  if (c&#x5B;&quot;title&quot;] === &quot;File viewer&quot; || c&#x5B;&quot;title&quot;] === &quot;File and Media viewer&quot;) {\n\tif (c.data.webPartData.properties.file.endsWith('.mp4')) {\n\t  srcUrl = c.data.webPartData.properties.webAbsoluteUrl + '\/_layouts\/15\/stream.aspx?id=' + c.data.webPartData.properties.file.replace('remove the tenant part', '');\n\t  return true;\n\t}\n\treturn false;\n  }\n  return false;\n});\nif (result) return `&lt;iframe width=&quot;640&quot; height=&quot;420&quot; src=&quot;${srcUrl}&quot; allowfullscreen style=&quot;border:none;&quot;&gt;&lt;\/iframe&gt;`;\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>With the New Stream feature video content can be saved in a document library without the need for a dedicated portal like Classic Stream.To reference a video on a SharePoint page the FileViewer component can be used. A custom video &#8230; <a class=\"more-link\" href=\"https:\/\/www.itidea.nl\/index.php\/creating-seamless-video-galleries-with-new-stream-and-sharepoint-components\/\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,41],"tags":[37],"class_list":["post-2879","post","type-post","status-publish","format-standard","hentry","category-office-365","category-sharepoint","tag-office365"],"_links":{"self":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/comments?post=2879"}],"version-history":[{"count":1,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2879\/revisions"}],"predecessor-version":[{"id":2880,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2879\/revisions\/2880"}],"wp:attachment":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/media?parent=2879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/categories?post=2879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/tags?post=2879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}