public static string GetSourceUrl(string channelName, bool livePreview) { string liveSourceUrl = string.Empty; string settingKey = Constants.AppSettingKey.AzureMedia; string[] liveAccount = AppSetting.GetValue(settingKey, true); if (liveAccount.Length > 0) { MediaClient mediaClient = new MediaClient(liveAccount[0], liveAccount[1]); IChannel channel = mediaClient.GetEntityByName(MediaEntity.Channel, channelName, true) as IChannel; if (channel != null && channel.State == ChannelState.Running) { if (livePreview) { liveSourceUrl = channel.Preview.Endpoints.First().Url.ToString(); } else { IProgram program = channel.Programs.First(); if (program.State == ProgramState.Running) { liveSourceUrl = mediaClient.GetLocatorUrl(program.Asset, LocatorType.OnDemandOrigin, null); } } } } return(liveSourceUrl); }
private static IStreamingEndpoint GetStreamingEndpoint(MediaClient mediaClient) { IStreamingEndpoint streamingEndpoint = null; IStreamingEndpoint[] streamingEndpoints = mediaClient.GetEntities(MediaEntity.StreamingEndpoint) as IStreamingEndpoint[]; if (streamingEndpoints.Length > 1) { streamingEndpoint = mediaClient.GetEntityByName(MediaEntity.StreamingEndpoint, Constant.Media.Stream.DefaultEndpointName) as IStreamingEndpoint; } else if (streamingEndpoints.Length == 1) { streamingEndpoint = streamingEndpoints[0]; } return(streamingEndpoint); }