From 692cca06607d8e7f8d3cba706ef0ee7907034fee Mon Sep 17 00:00:00 2001
From: Richard <richard@fsmpi.rwth-aachen.de>
Date: Tue, 13 Oct 2020 01:56:54 +0200
Subject: [PATCH] sort video links by mime type and resolution

---
 free.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/free.js b/free.js
index 27936e3..6cf65dc 100644
--- a/free.js
+++ b/free.js
@@ -11,6 +11,15 @@ if (window.location.host === 'engage.streaming.rwth-aachen.de') {
       window._meta = meta
       let videoTracks = meta['search-results'].result.mediapackage.media.track
         .filter(t=> t.mimetype.startsWith('video/') && t.url.startsWith('http'))
+        .sort((a,b) => {
+          let mimeComp = a.mimetype.localeCompare(b.mimetype)
+          if (mimeComp) return mimeComp
+          let resAI = parseInt(a.video.resolution)
+          let resBI = parseInt(b.video.resolution)
+          if (resAI > resBI) return 1
+          if (resAI < resBI) return -1
+          return 0
+        })
       videoTracks.forEach(t=>console.log(t.id, t.mimetype, t.video.resolution, t.url))
       if (inFrame) {
         console.debug('posting message')
-- 
GitLab