Remote playback almost working
This commit is contained in:
@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Aurora.Proto.Party;
|
||||
using Aurora.Proto.Events;
|
||||
using Aurora.Proto.General;
|
||||
using Aurora.Services.EventManager;
|
||||
using Aurora.Services;
|
||||
using Aurora.Models.Media;
|
||||
@ -104,7 +105,11 @@ namespace Aurora.RemoteImpl
|
||||
metadata = media.Metadata as AudioMetadata;
|
||||
|
||||
RemoteMediaData data = new RemoteMediaData();
|
||||
data.Title = metadata.Title == null ? metadata.Title : "";
|
||||
data.Id = media.Id;
|
||||
if (metadata.Title != null)
|
||||
{
|
||||
data.Title = metadata.Title;
|
||||
}
|
||||
if (metadata.Artist != null)
|
||||
{
|
||||
data.Artist = metadata.Artist;
|
||||
@ -130,5 +135,24 @@ namespace Aurora.RemoteImpl
|
||||
return Task.FromResult(mediaList);
|
||||
|
||||
}
|
||||
|
||||
public override async Task GetSongStream(SongRequest request,
|
||||
Grpc.Core.IServerStreamWriter<Chunk> responseStream,
|
||||
Grpc.Core.ServerCallContext context)
|
||||
{
|
||||
BaseMedia song = LibraryService.Instance.GetSong(request.Id);
|
||||
song.Load();
|
||||
|
||||
//Send stream
|
||||
Console.WriteLine("Begin sending file");
|
||||
byte[] buffer = new byte[2048]; // read in chunks of 2KB
|
||||
int bytesRead;
|
||||
while ((bytesRead = song.DataStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
Google.Protobuf.ByteString bufferByteString = Google.Protobuf.ByteString.CopyFrom(buffer);
|
||||
await responseStream.WriteAsync(new Chunk { Content = bufferByteString });
|
||||
}
|
||||
Console.WriteLine("Done sending file");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using Aurora.Proto.Playback;
|
||||
using Aurora.Proto.General;
|
||||
using Aurora.Models;
|
||||
|
||||
namespace Aurora.RemoteImpl
|
||||
{
|
||||
public class RemotePlaybackServiceImpl : RemotePlaybackService.RemotePlaybackServiceBase
|
||||
{
|
||||
|
||||
public RemotePlaybackServiceImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override Task GetPartyStream(Empty empty,
|
||||
Grpc.Core.IServerStreamWriter<Chunk> responseStream,
|
||||
Grpc.Core.ServerCallContext context)
|
||||
{
|
||||
throw new NotImplementedException("Working on it");
|
||||
// //Send stream
|
||||
// string cwd = Directory.GetCurrentDirectory();
|
||||
// using (FileStream fs = System.IO.File.OpenRead(Path.Combine(cwd, request.FileName)))
|
||||
// {
|
||||
// Console.WriteLine("Begin sending file");
|
||||
// byte[] buffer = new byte[2048]; // read in chunks of 2KB
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
|
||||
// {
|
||||
// Google.Protobuf.ByteString bufferByteString = Google.Protobuf.ByteString.CopyFrom(buffer);
|
||||
// await responseStream.WriteAsync(new Chunk { Content = bufferByteString });
|
||||
// }
|
||||
// Console.WriteLine("Done sending file");
|
||||
// };
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user