コード例 #1
0
ファイル: module.php プロジェクト: Nall-chan/IPSSqueezeBox
 private function SetCover()
 {
     $CoverID = @IPS_GetObjectIDByIdent('CoverIMG', $this->InstanceID);
     if ($CoverID === false) {
         $CoverID = IPS_CreateMedia(1);
         IPS_SetParent($CoverID, $this->InstanceID);
         IPS_SetIdent($CoverID, 'CoverIMG');
         IPS_SetName($CoverID, 'Cover');
         IPS_SetPosition($CoverID, 27);
         IPS_SetMediaCached($CoverID, true);
         IPS_SetMediaFile($CoverID, "media" . DIRECTORY_SEPARATOR . "Cover_" . $this->InstanceID . ".png", False);
     }
     $ParentID = $this->GetParent();
     if (!($ParentID === false)) {
         $Host = IPS_GetProperty($ParentID, 'Host') . ":" . IPS_GetProperty($ParentID, 'Webport');
         $Size = $this->ReadPropertyString("CoverSize");
         $PlayerID = rawurlencode($this->Address);
         $CoverRAW = @Sys_GetURLContent("http://" . $Host . "/music/current/" . $Size . ".png?player=" . $PlayerID);
         if (!($CoverRAW === false)) {
             IPS_SetMediaContent($CoverID, base64_encode($CoverRAW));
         }
     }
     return;
 }
コード例 #2
0
ファイル: module.php プロジェクト: Nall-chan/IPSVoiceRSS
 public function GenerateMediaObjectEx(string $Text, int $MediaID, string $Format, string $Codec, string $Language)
 {
     if ($MediaID == 0) {
         $MediaID = @IPS_GetObjectIDByIdent('Voice', $this->InstanceID);
     }
     if ($MediaID > 0) {
         if (IPS_MediaExists($MediaID) === false) {
             trigger_error('MediaObject not exists.', E_USER_NOTICE);
         }
         return false;
         if (IPS_GetMedia($MediaID)['MediaType'] != 2) {
             trigger_error('Wrong MediaType', E_USER_NOTICE);
         }
         return false;
     }
     $raw = $this->LoadTTSFile($Text, '', 0, $Format, $Codec, $Language, true);
     if ($raw === false) {
         return false;
     }
     if ($MediaID === false) {
         $MediaID = IPS_CreateMedia(2);
         IPS_SetMediaCached($MediaID, true);
         IPS_SetName($MediaID, 'Voice');
         IPS_SetParent($MediaID, $this->InstanceID);
         IPS_SetIdent($MediaID, 'Voice');
     }
     $Filename = 'media' . DIRECTORY_SEPARATOR . $MediaID . '.' . strtolower($Codec);
     IPS_SetMediaFile($MediaID, $Filename, False);
     IPS_SetMediaContent($MediaID, base64_encode($raw));
     IPS_SetInfo($MediaID, $Text);
     return $MediaID;
 }