BililiveRecorder/BililiveRecorder.Core/Recorder.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2018-03-21 20:56:56 +08:00
using NLog;
using System;
2018-03-12 18:57:20 +08:00
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
namespace BililiveRecorder.Core
{
public class Recorder
{
2018-03-21 20:56:56 +08:00
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public ObservableCollection<RecordedRoom> Rooms { get; } = new ObservableCollection<RecordedRoom>();
public Settings Settings { get; } = new Settings();
2018-03-20 00:12:32 +08:00
public Recorder()
{
}
2018-03-12 18:57:20 +08:00
2018-03-24 02:27:58 +08:00
/// <summary>
/// 添加直播间到录播姬
/// </summary>
/// <param name="roomid">房间号(支持短号)</param>
/// <exception cref="ArgumentOutOfRangeException"/>
2018-03-21 20:56:56 +08:00
public void AddRoom(int roomid)
{
if (roomid <= 0)
throw new ArgumentOutOfRangeException(nameof(roomid), "房间号需要大于0");
2018-03-21 22:41:34 +08:00
var rr = new RecordedRoom(Settings, roomid);
2018-03-24 02:27:58 +08:00
rr.RecordInfo.SavePath = Settings.SavePath;//TODO: 录制文件保存位置
2018-03-21 22:41:34 +08:00
Rooms.Add(rr);
2018-03-21 20:56:56 +08:00
}
2018-03-24 02:27:58 +08:00
/// <summary>
/// 从录播姬移除直播间
/// </summary>
/// <param name="rr">直播间</param>
public void RemoveRoom(RecordedRoom rr)
{
rr.Stop();
rr.StopRecord();
2018-03-24 08:34:57 +08:00
Rooms.Remove(rr); // TODO: fix
2018-03-24 02:27:58 +08:00
}
2018-03-12 18:57:20 +08:00
}
}