M
M
Maxim2019-02-08 09:01:27
Angular
Maxim, 2019-02-08 09:01:27

How to play the downloaded/recorded video from the server on the site (NOT broadcast from IP-camera)?

The folder on the server contains the downloaded/recorded video file in MP4 format. I need to connect to a server remotely and play a file on a client page.
On the client:
TS:

export class VideoLayoutPartComponent implements OnInit {
  @Input() part: LayoutPart;
  videoSource: SafeUrl;

  constructor(private httpService: HttpService, private configurationService: ConfigurationService) { }

  ngOnInit(): void {
    this.configurationService.configurationUpdated.subscribe(() => this.configurationUpdated());
  }

  private configurationUpdated() {
    return this.httpService.get('configuration/getVideo?videoUID='+ this.part.properties['referenceUID']).subscribe(videoData => {
      this.videoSource = videoData;
    });
  }

On the client:
HTML:
<video width="320" height="240" controls="controls" preload="auto">
    <source src="{{videoSource}}}" type="video/mp4">
</video>

On Server
Configuration.cs:
[HttpGet]
    public BitArray GetVideo(Guid? videoUid)
    {
        return VideoFactory.GetVideo(videoUid);
    }

On the server:
VideoFactory.cs:
public static BitArray GetVideo(Guid? videoUID)
{
    if (videoUID.HasValue && videoUID != Guid.Empty)
    {
      foreach (var fileInfo in contentFolder.GetFiles())
      {
    if (Path.GetFileNameWithoutExtension(fileInfo.FullName) == videoUID.ToString())
      {
         byte[] bytes = File.ReadAllBytes(fileInfo.FullName);
         return new BitArray(bytes);
          }
       }
     }
}

The reference UID comes from the client, the server finds the video, successfully processes it into a byte array, and sends it back. But the client does not accept the bytes and the browser freezes. Please help me understand how to accept array by client and play video

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
none7, 2019-02-08
@none7

videoSource: SafeUrl;
videoData: ???;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question