Browse Source

now playing work

causefx 8 years ago
parent
commit
151ef74b8f
5 changed files with 62 additions and 4 deletions
  1. 21 2
      api/functions/homepage-connect-functions.php
  2. 3 0
      css/organizr.css
  3. 1 0
      index.php
  4. 10 1
      js/custom.js
  5. 27 1
      js/functions.js

+ 21 - 2
api/functions/homepage-connect-functions.php

@@ -96,15 +96,34 @@ function resolvePlexItem($item) {
             $plexItem['nowPlayingTitle'] = (string)$item['title'];
             $plexItem['nowPlayingBottom'] = (string)$item['year'];
 		}
-        $plexItem['elapsed'] = isset($item['viewOffset']) ? (int)$item['viewOffset'] : null;
-        $plexItem['elapsed'] = isset($plexItem['elapsed']) && $plexItem['elapsed'] == 0 ? null : $plexItem['elapsed'];
+        $plexItem['elapsed'] = isset($item['viewOffset']) && $item['viewOffset'] !== '0' ? (int)$item['viewOffset'] : null;
         $plexItem['duration'] = isset($item['duration']) ? (int)$item['duration'] : (int)$item->Media['duration'];
         $plexItem['watched'] = ($plexItem['elapsed'] && $plexItem['duration'] ? floor(($plexItem['elapsed'] / $plexItem['duration']) * 100) : 0);
         $plexItem['transcoded'] = isset($item->TranscodeSession['progress']) ? floor((int)$item->TranscodeSession['progress']- $plexItem['watched']) : '';
         $plexItem['stream'] = isset($item->Media->Part->Stream['decision']) ? (string)$item->Media->Part->Stream['decision']: '';
         $plexItem['id'] = str_replace('"', '', (string)$item->Player['machineIdentifier']);
+        $plexItem['session'] = (string)$item->Session['id'];
+        $plexItem['bandwidth'] = (string)$item->Session['bandwidth'];
+        $plexItem['bandwidthType'] = (string)$item->Session['location'];
+        $plexItem['sessionType'] = isset($item->TranscodeSession['progress']) ? 'Transcoding' : 'Direct Playing';
         $plexItem['state'] = (((string)$item->Player['state'] == "paused") ? "pause" : "play");
         $plexItem['user'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->User['title'] : "";
+        $plexItem['userThumb'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->User['thumb'] : "";
+        $plexItem['userAddress'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->Player['address'] : "x.x.x.x";
+        $plexItem['userStream'] = array(
+            'platform' => (string)$item->Player['platform'],
+            'device' => (string)$item->Player['device'],
+            'stream' => (string)$item->Media->Part['decision'].($item->TranscodeSession['throttled'] == '1' ? ' (Throttled)': ''),
+            'throttled' => ($item->TranscodeSession['throttled'] == 1) ? true : false,
+            'sourceVideoCodec' => (string)$item->TranscodeSession['sourceVideoCodec'],
+            'videoCodec' => (string)$item->TranscodeSession['videoCodec'],
+            'audioCodec' => (string)$item->TranscodeSession['audioCodec'],
+            'sourceAudioCodec' => (string)$item->TranscodeSession['sourceAudioCodec'],
+            'videoDecision' => streamType((string)$item->TranscodeSession['videoDecision']),
+            'audioDecision' => streamType((string)$item->TranscodeSession['audioDecision']),
+            'container' => (string)$item->TranscodeSession['container'],
+            'audioChannels' => (string)$item->TranscodeSession['audioChannels']
+        );
         $plexItem['address'] = $GLOBALS['plexTabURL'] ? $GLOBALS['plexTabURL']."/web/index.html#!/server/".$GLOBALS['plexID']."/details?key=/library/metadata/".$item['ratingKey'] : "https://app.plex.tv/web/app#!/server/".$GLOBALS['plexID']."/details?key=/library/metadata/".$item['ratingKey'];
         $plexItem['nowPlayingOriginalImage'] = 'api/?v1/image&source=plex&img='.$plexItem['nowPlayingThumb'].'&height='.$nowPlayingHeight.'&width='.$nowPlayingWidth.'&key='.$plexItem['nowPlayingKey'].'$'.randString();
         $plexItem['originalImage'] = 'api/?v1/image&source=plex&img='.$plexItem['thumb'].'&height='.$height.'&width='.$width.'&key='.$plexItem['key'].'$'.randString();

+ 3 - 0
css/organizr.css

@@ -157,3 +157,6 @@ object-fit: contain;
 .nowPlayingHover{
   margin-bottom: 14px;
 }
+.nowPlayingUserThumb:hover{
+  opacity: 0;
+}

+ 1 - 0
index.php

@@ -21,6 +21,7 @@
 	<link href="plugins/bower_components/switchery/dist/switchery.min.css" rel="stylesheet" />
 	<link href="plugins/bower_components/jquery-asColorPicker-master/css/asColorPicker.css" rel="stylesheet">
 	<link href="plugins/bower_components/dropzone-master/dist/dropzone.css" rel="stylesheet" type="text/css" />
+	<link href="plugins/bower_components/css-chart/css-chart.css" rel="stylesheet">
 	<link id="style" href="css/dark.css?v=<?php echo $GLOBALS['installedVersion']; ?>" rel="stylesheet">
 	<link href="css/organizr.css?v=<?php echo $GLOBALS['installedVersion']; ?>" rel="stylesheet">
 	<?php echo pluginFiles('css'); ?>

+ 10 - 1
js/custom.js

@@ -405,7 +405,16 @@ function pageLoad(){
             }
         }
     });
-
+    // Inline popups
+    $('.inline-popups').magnificPopup({
+      removalDelay: 500, //delay removal by X to allow out-animation
+      callbacks: {
+        beforeOpen: function() {
+           this.st.mainClass = this.st.el.attr('data-effect');
+        }
+      },
+      midClick: true // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
+    });
     $('.simple-ajax-popup-align-top').magnificPopup({
         type: 'ajax',
         alignTop: true,

+ 27 - 1
js/functions.js

@@ -1829,6 +1829,7 @@ function buildPlexStreamItem(array){
 			default:
 
 		}
+		var userThumb = (v.userThumb) ? '<img src="'+v.userThumb+'" class="nowPlayingUserThumb" alt="User">' : '';
 		cards += `
 		<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 nowPlayingItem">
 			<div class="white-box">
@@ -1836,7 +1837,7 @@ function buildPlexStreamItem(array){
 					<div class="el-card-avatar el-overlay-1 m-b-0">`+bg+`<img class="imageSource" style="width:`+width+`%;margin-left: auto;margin-right: auto;" src="`+v.nowPlayingImageURL+`">
 						<div class="el-overlay">
 							<ul class="el-info p-t-20 m-t-20">
-								<li><a class="btn default btn-outline" href="javascript:void(0);"><i class="icon-graph"></i></a></li>
+								<li><a class="btn default btn-outline inline-popups" href="#`+v.session+`" data-effect="mfp-zoom-out"><i class="icon-graph"></i></a></li>
 								<li><a class="btn default btn-outline image-popup-vertical-fit" href="`+v.nowPlayingImageURL+`"><i class="icon-info"></i></a></li>
 								<li><a class="btn default btn-outline" href="javascript:void(0);"><i class="icon-share-alt"></i></a></li>
 								<li><a class="btn default btn-outline refreshImage" data-image="`+v.nowPlayingOriginalImage+`" href="javascript:void(0);"><i class="icon-refresh"></i></a></li>
@@ -1859,6 +1860,31 @@ function buildPlexStreamItem(array){
 				</div>
 			</div>
 		</div>
+		<div id="`+v.session+`" class="white-popup mfp-with-anim mfp-hide">
+			<div class="row">
+				<div class="col-md-6 col-md-offset-3">
+
+					<div class="white-box m-b-0 bg-info">
+						<h3 class="text-white box-title m-b-0">`+v.sessionType+`<span class="pull-right"><i class="mdi mdi-network-upload"></i> `+v.bandwidth+` kbps</span></h3>
+					</div>
+					<div class="white-box">
+						<div class="row">
+							<div class="p-l-20 p-r-20">
+								<div class="pull-left">
+									<span class="text-uppercase"><i class="mdi mdi-`+v.bandwidthType+`"></i> `+v.bandwidthType+`</span>
+									<span class="text-uppercase"><i class="mdi mdi-account-network"></i> `+v.userAddress+`</span>
+									<div class="text-muted m-t-20 text-uppercase"><span class="text-uppercase"><i class="mdi mdi-play-circle-outline"></i> Stream: `+v.userStream.stream+`</span></div>
+									<div class="text-muted m-t-20 text-uppercase"><span class="text-uppercase"><i class="mdi mdi-video"></i> Video: `+v.userStream.videoDecision+`</span></div>
+									<div class="text-muted m-t-20 text-uppercase"><span class="text-uppercase"><i class="mdi mdi-speaker"></i> Audio: `+v.userStream.audioDecision+`</span></div>
+								</div>
+								<div data-label="`+v.watched+`%" class="css-bar css-bar-`+Math.ceil(v.watched/5)*5+` css-bar-lg m-b-0  css-bar-info pull-right">`+userThumb+`</div>
+							</div>
+						</div>
+					</div>
+
+                </div>
+			</div>
+		</div>
 		`;
 		if(contains(''+count, end) || count == total ){ cards += '</div><!--end-->'; };