/// <summary> /// Create Timeshifting filename based on RTSP url, UNC or real path. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static string GetFileNameForTimeshifting() { bool useRTSP = TVHome.UseRTSP(); string fileName = ""; if (!useRTSP) //SMB mode { bool fileExists = File.Exists(TVHome.Card.TimeShiftFileName); if (!fileExists) // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.TimeshiftingPath().Length > 0) { //use user defined timeshifting folder as either UNC or network drive fileName = Path.GetFileName(TVHome.Card.TimeShiftFileName); fileName = TVHome.TimeshiftingPath() + "\\" + fileName; } else // use automatic UNC path { fileName = TVHome.Card.TimeShiftFileName.Replace(":", ""); fileName = "\\\\" + RemoteControl.HostName + "\\" + fileName; } } else { fileName = TVHome.Card.TimeShiftFileName; } } else //RTSP mode, get RTSP url { fileName = TVHome.Card.RTSPUrl; } return(fileName); }
/// <summary> /// Create Recording filename based on RTSP url, UNC or real path. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static string GetFileNameForRecording(Recording rec) { bool useRTSP = TVHome.UseRTSP(); string fileName = ""; if (!useRTSP) //SMB mode { bool fileExists = File.Exists(rec.FileName); if (!fileExists) // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.RecordingPath().Length > 0) { //use user defined recording folder as either UNC or network drive fileName = Path.GetFileName(rec.FileName); string fileNameSimple = TVHome.RecordingPath() + "\\" + fileName; fileExists = File.Exists(fileNameSimple); if (!fileExists) //maybe file exist in folder, schedules recs often appear in folders, no way to intelligently determine this. { DirectoryInfo dirInfo = Directory.GetParent(rec.FileName); if (dirInfo != null) { string parentFolderName = dirInfo.Name; fileName = TVHome.RecordingPath() + "\\" + parentFolderName + "\\" + fileName; } } else { fileName = fileNameSimple; } } else // use automatic UNC path { fileName = rec.FileName.Replace(":", ""); fileName = "\\\\" + RemoteControl.HostName + "\\" + fileName; } } else //file exists, return it. { fileName = rec.FileName; } } else //RTSP mode, get RTSP url for file. { fileName = TVHome.TvServer.GetStreamUrlForFileName(rec.IdRecording); } return(fileName); }
public static bool PlayRecording(Recording rec, double startOffset, g_Player.MediaType mediaType) { string fileName = GetFileNameForRecording(rec); bool useRTSP = TVHome.UseRTSP(); string chapters = useRTSP ? TVHome.TvServer.GetChaptersForFileName(rec.IdRecording) : null; Log.Info("PlayRecording:{0} - using rtsp mode:{1}", fileName, useRTSP); if (g_Player.Play(fileName, mediaType, chapters)) { if (Utils.IsVideo(fileName) && !g_Player.IsRadio) { g_Player.ShowFullScreenWindow(); } if (startOffset > 0) { g_Player.SeekAbsolute(startOffset); } else if (startOffset == -1) { // 5 second margin is used that the TsReader wont stop playback right after it has been started double dTime = g_Player.Duration - 5; g_Player.SeekAbsolute(dTime); } TvRecorded.SetActiveRecording(rec); //populates recording metadata to g_player; g_Player.currentFileName = rec.FileName; g_Player.currentTitle = GetDisplayTitle(rec); g_Player.currentDescription = rec.Description; rec.TimesWatched++; rec.Persist(); return(true); } return(false); }
/// <summary> /// Create Recording filename based on RTSP url, UNC or real path. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static string GetFileNameForRecording(Recording rec) { bool useRTSP = TVHome.UseRTSP(); string fileName = ""; if (!useRTSP) //SMB mode { bool fileExists = File.Exists(rec.FileName); if (!fileExists) // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.RecordingPath().Length > 0) { //use user defined recording folder as either UNC or network drive fileName = Path.GetFileName(rec.FileName); string fileNameSimple = TVHome.RecordingPath() + "\\" + fileName; fileExists = File.Exists(fileNameSimple); if (!fileExists) //maybe file exist in folder, schedules recs often appear in folders, no way to intelligently determine this. { DirectoryInfo dirInfo = Directory.GetParent(rec.FileName); if (dirInfo != null) { string parentFolderName = dirInfo.Name; fileName = TVHome.RecordingPath() + "\\" + parentFolderName + "\\" + fileName; } fileExists = File.Exists(fileName); //check with foldername from set UNC Path if (!fileExists) { //Get last foldername of RecordingPath string parentFolderNameRecording = Path.GetFileName(TVHome.RecordingPath().TrimEnd(Path.DirectorySeparatorChar)); parentFolderNameRecording = @"\" + parentFolderNameRecording.Replace(@"\", "\"\"") + @"\"; //Replace "\" with "" and add a "\" at the beginning and end (good for searching the path in the recording filename) //Search the last folder of the set recording path in var rec.FileName int iPos = rec.FileName.IndexOf(parentFolderNameRecording); if (iPos != -1) { //We have found the last Folder of the set recording path in var rec.FileName //Cut the first string (ussaly the TV Server Local Path) and remove the last Recording Folder from string fileName = rec.FileName.Substring(iPos).Replace(parentFolderNameRecording, ""); //Add the recording path fileName = TVHome.RecordingPath() + "\\" + fileName; } } } else { fileName = fileNameSimple; } } else // use automatic UNC path { fileName = rec.FileName.Replace(":", ""); fileName = "\\\\" + RemoteControl.HostName + "\\" + fileName; } } else //file exists, return it. { fileName = rec.FileName; } } else //RTSP mode, get RTSP url for file. { fileName = TVHome.TvServer.GetStreamUrlForFileName(rec.IdRecording); } return(fileName); }