import {Channels} from '@phenixrts/sdk';
import type PhenixChannel from '@phenixrts/sdk/types/sdk/channels/Channel';
import {ApplicationCredentials, Channel} from '@techniker-me/pcast-api';
import PhenixEdgeAuthService from './EdgeAuth.service';



export default class PhenixChannelService {
  private constructor() {
    throw new Error('PhenixChannelService is a static class that may not be instantiated');
  }

  public static subscribeToChannel({id, secret}: ApplicationCredentials, channel: Channel, videoElement: HTMLVideoElement): PhenixChannel {
    const token = PhenixEdgeAuthService.createChannelToken({id, secret, channelId: channel.channelId});

    console.log('token', token);
    console.log('channel', channel);
    
    return Channels.createChannel({
      token,
      videoElement
    });
  }
}
