public static void StopProgram(AMSChannel channel, AMSEvent eventData, IProgramRelativeEntity retProgramInfo) { if (channel != null && channel.AMSID.IsNotEmpty()) { CloudMediaContext context = MediaServiceAccountSettings.GetConfig().Accounts.GetCloudMediaContext(channel.AMSAccountName); IChannel amsChannel = GetChannelByID(context, channel.AMSID); if (amsChannel != null) { IProgram program = GetProgramByEvent(amsChannel, eventData); if (program != null) { if (program.State == ProgramState.Running) { TraceOperation("Stop Program {0}", () => program.Stop(), program.Name); } program.FillAMSEvent(channel, retProgramInfo); if (retProgramInfo.State == AMSEventState.NotStart) { retProgramInfo.State = AMSEventState.Completed; } } else { retProgramInfo.State = AMSEventState.Completed; } } } }
public static void FillAMSEvent(this IProgram program, AMSChannel channel, IProgramRelativeEntity eventData) { if (program != null) { eventData.AMSProgramID = program.Id; eventData.State = program.State.ToAMSEventState(); IAsset asset = program.Asset; if (asset != null) { IAssetFile file = asset.AssetFiles.AsEnumerable().FirstOrDefault(a => a.Name.EndsWith(".ism")); if (file != null) { ILocator locator = asset.Locators.FirstOrDefault(); if (locator != null) { eventData.DefaultPlaybackUrl = locator.Path + file.Name + "/manifest"; eventData.CDNPlaybackUrl = GetCDNPlaybackUrl(locator.Path, eventData.DefaultPlaybackUrl, file.Name, channel.CDNPrefixMode, channel.CDNPrefix); } } } } }