ソースを参照

Fix PLEX invite to have back button

causefx 8 年 前
コミット
c0ca8cb3fc
3 ファイル変更23 行追加12 行削除
  1. 12 11
      functions.php
  2. 10 0
      index.php
  3. 1 1
      settings.php

+ 12 - 11
functions.php

@@ -515,7 +515,7 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName
             $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
             $elapsed = $moreInfo['PlayState']['PositionTicks'];
             $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
-            $watched = floor(($elapsed / $duration) * 100);
+            $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
             //$transcoded = floor($item->TranscodeSession['progress']- $watched);
             $stream = $moreInfo['PlayState']['PlayMethod'];
             $user = $role == "admin" ? $moreInfo['UserName'] : "";
@@ -551,7 +551,7 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName
         $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
         $elapsed = $moreInfo['PlayState']['PositionTicks'];
         $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
-        $watched = floor(($elapsed / $duration) * 100);
+        $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
         //$transcoded = floor($item->TranscodeSession['progress']- $watched);
         $stream = $moreInfo['PlayState']['PlayMethod'];
         $user = $role == "admin" ? $moreInfo['UserName'] : "";
@@ -612,11 +612,11 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName
     }else{
         $height = 281;
         $width = 500;
-        $imageType = isset($itemDetails['ImageTags']['Thumb']) ?	"Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
+        $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
         $key = $itemDetails['Id'] . "-np";
         $elapsed = $moreInfo['PlayState']['PositionTicks'];
         $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
-        $watched = floor(($elapsed / $duration) * 100);
+        $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
         //$transcoded = floor($item->TranscodeSession['progress']- $watched);
         $stream = $moreInfo['PlayState']['PlayMethod'];
         $user = $role == "admin" ? $moreInfo['UserName'] : "";
@@ -685,7 +685,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
                 $duration = $item['duration'];
-                $watched = floor(($elapsed / $duration) * 100);
+                $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
                 $user = $role == "admin" ? $item->User['title'] : "";
@@ -716,7 +716,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
                 $duration = $item['duration'];
-                $watched = floor(($elapsed / $duration) * 100);
+                $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
                 $user = $role == "admin" ? $item->User['title'] : "";
@@ -748,9 +748,10 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $width = 500;
                 $thumb = $item['art'];
                 $key = $item['ratingKey'] . "-np";
+				$extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
                 $elapsed = $item['viewOffset'];
                 $duration = $item['duration'];
-                $watched = floor(($elapsed / $duration) * 100);
+                $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
                 $user = $role == "admin" ? $item->User['title'] : "";
@@ -763,8 +764,8 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                     'audio' => " ".streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
                 ));
                 $state = (($item->Player['state'] == "paused") ? "pause" : "play");
-                $topTitle = '<h5 class="text-center zero-m elip">'.$title.' [Trailer/Clip]</h5>';
-                $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
+                $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
+                $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
                 if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
             }
             break;
@@ -786,7 +787,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
                 $duration = $item['duration'];
-                $watched = floor(($elapsed / $duration) * 100);
+                $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
                 $user = $role == "admin" ? $item->User['title'] : "";
@@ -819,7 +820,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
                 $duration = $item['duration'];
-                $watched = floor(($elapsed / $duration) * 100);
+                $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
                 $user = $role == "admin" ? $item->User['title'] : "";

+ 10 - 0
index.php

@@ -1084,6 +1084,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 										</div>
 
 										<button id="useInviteForm_submit" style="background:<?=$topbar;?>;" type="submit" class="btn btn-block btn-info text-uppercase waves" value="useInvite"><text style="color:<?=$topbartext;?>;"><?php echo $language->translate("JOIN");?></text></button>
+										<button id="plexYesGoBack" style="background:<?=$topbartext;?>;" class="btn btn-block btn-info text-uppercase waves"><text style="color:<?=$topbar;?>;"><?php echo $language->translate("GO_BACK");?></text></button>
 
 									</form>
 
@@ -1096,6 +1097,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 										</div>
 
 										<button id="joinPlexForm_submit" style="background:<?=$topbar;?>;" type="submit" class="btn btn-block btn-info text-uppercase waves" value="useInvite"><text style="color:<?=$topbartext;?>;"><?php echo $language->translate("SIGN_UP");?></text></button>
+										<button id="plexNoGoBack" style="background:<?=$topbartext;?>;" class="btn btn-block btn-info text-uppercase waves"><text style="color:<?=$topbar;?>;"><?php echo $language->translate("GO_BACK");?></text></button>
 
 									</form> 
 
@@ -1219,6 +1221,14 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
             $("#switchCreateUser").toggle();
             $("#welcomeGoBack").toggle();
         });
+		$("#plexNoGoBack").click(function(){
+            $("#joinPlexForm").toggle();
+            $("#chooseMethod").toggle();
+        });
+		$("#plexYesGoBack").click(function(){
+            $("#useInviteForm").toggle();
+            $("#chooseMethod").toggle();
+        });	
         $("#welcomeGoBack2").click(function(){
             $( "form[id^='login']" ).toggle();
             $("#userPassForm").toggle();

+ 1 - 1
settings.php

@@ -2057,7 +2057,7 @@ echo buildSettings(
 
                                                     <div class="form-group">
 
-                                                        <input type="text" class="form-control material" name="username" placeholder="<?php echo $language->translate("USERNAME");?>" autocorrect="off" autocapitalize="off" value="">
+                                                        <input type="text" class="form-control material" name="username" placeholder="<?php echo $language->translate("USERNAME_NAME");?>" autocorrect="off" autocapitalize="off" value="">
 
                                                     </div>