本文整理汇总了C#中Microsoft.WindowsAzure.MediaServices.Client.CloudMediaContext类的典型用法代码示例。如果您正苦于以下问题:C# CloudMediaContext类的具体用法?C# CloudMediaContext怎么用?C# CloudMediaContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudMediaContext类属于Microsoft.WindowsAzure.MediaServices.Client命名空间,在下文中一共展示了CloudMediaContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetStorageAccountMappingFromConfig
/// <summary>
/// Gets the storage account mapping from config
/// </summary>
/// <param name="context">The context.</param>
/// <returns></returns>
public static Dictionary<CloudStorageAccount, IStorageAccount> GetStorageAccountMappingFromConfig(CloudMediaContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
var storageAccounts = new Dictionary<CloudStorageAccount, IStorageAccount>();
var registeredAccounts = context.StorageAccounts.ToList();
foreach (var registeredAccount in registeredAccounts)
{
var connectionString =ConfigurationManager.AppSettings["Storage_" + registeredAccount.Name];
//If user don't provide all connection strings to storage accounts we are skipping this storage account.
//We also skipping if connection string is not correct
if (!String.IsNullOrEmpty(connectionString))
{
CloudStorageAccount storageAccount = null;
CloudStorageAccount.TryParse(connectionString, out storageAccount);
if (storageAccount != null)
{
storageAccounts.Add(storageAccount, registeredAccount);
}
{
Debug.WriteLine("Unable to parse connection string for storage account {0}", registeredAccount.Name);
}
}
else
{
Debug.WriteLine("Storage account {0} has missing setting with connection string in App.config", registeredAccount.Name);
}
}
return storageAccounts;
}
开发者ID:shushengli,项目名称:azure-sdk-for-media-services,代码行数:40,代码来源:StorageAccountConfigHelper.cs
示例2: AssetInformation
public AssetInformation(Mainform mainform, CloudMediaContext context)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
myMainForm = mainform;
myContext = context;
}
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:7,代码来源:AssetInformation.cs
示例3: AssetHelper
public AssetHelper(CloudMediaContext context, Encoder encoder, RestServices restServices, TextWriter textWriter)
{
this.context = context;
this.encoder = encoder;
this.restServices = restServices;
this.textWriter = textWriter;
}
开发者ID:AppliedIS,项目名称:wams-preview,代码行数:7,代码来源:AssetHelper.cs
示例4: Main
static void Main(string[] args)
{
// Create and cache the Media Services credentials in a static class variable.
_cachedCredentials = new MediaServicesCredentials(_mediaServicesAccountName, _mediaServicesAccountKey);
// Use the cached credentials to create CloudMediaContext.
_context = new CloudMediaContext(_cachedCredentials);
// Encoding and encrypting assets //////////////////////
// Load a single MP4 file.
IAsset asset = IngestSingleMP4File(_singleMP4File, AssetCreationOptions.None);
// Encode an MP4 file to a set of multibitrate MP4s.
// Then, package a set of MP4s to clear Smooth Streaming.
IAsset clearSmoothStreamAsset = ConvertMP4ToMultibitrateMP4sToSmoothStreaming(asset);
// Encrypt your clear Smooth Streaming to Smooth Streaming with PlayReady.
IAsset outputAsset = CreateSmoothStreamEncryptedWithPlayReady(clearSmoothStreamAsset);
// You can use the http://smf.cloudapp.net/healthmonitor player
// to test the smoothStreamURL URL.
string smoothStreamURL = outputAsset.GetSmoothStreamingUri().ToString();
Console.WriteLine("Smooth Streaming URL:");
Console.WriteLine(smoothStreamURL);
// You can use the http://dashif.org/reference/players/javascript/ player
// to test the dashURL URL.
string dashURL = outputAsset.GetMpegDashUri().ToString();
Console.WriteLine("MPEG DASH URL:");
Console.WriteLine(dashURL);
}
开发者ID:NewforceComputerTechnologies,项目名称:DevCamp,代码行数:30,代码来源:Program.cs
示例5: MultipleProcessor
public MultipleProcessor(CloudMediaContext context, IJob myJob = null)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
_context = context;
_myJob = myJob;
buttonTaskOptions1.Initialize(_context, true);
buttonTaskOptions2.Initialize(_context, true);
buttonTaskOptions3.Initialize(_context, true);
buttonTaskOptions4.Initialize(_context, true);
buttonTaskOptions5.Initialize(_context, true);
buttonTaskOptions1.Click += ButtonTaskOptions_Click;
buttonTaskOptions2.Click += ButtonTaskOptions_Click;
buttonTaskOptions3.Click += ButtonTaskOptions_Click;
buttonTaskOptions4.Click += ButtonTaskOptions_Click;
buttonTaskOptions5.Click += ButtonTaskOptions_Click;
if (_myJob != null) // we are in resubmit mode
{
textBoxConfiguration1.Text = _myJob.Tasks.FirstOrDefault().GetClearConfiguration();
radioButtonSingleJobForAllInputAssets.Checked = true;
panelJobMode.Enabled = false;
numericUpDownTasks.Enabled = false;
SelectedAssets = myJob.InputMediaAssets.ToList();
}
labelWarningJSON1.Text = labelWarningJSON2.Text = labelWarningJSON3.Text = labelWarningJSON4.Text = labelWarningJSON5.Text = string.Empty;
init = false;
}
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:30,代码来源:MultipleProcessor.cs
示例6: GetActiveJobs
public IEnumerable<Video> GetActiveJobs()
{
var activeJobs = this.context.Videos.Where(v => !string.IsNullOrEmpty(v.JobId));
if (activeJobs.Any())
{
var mediaContext = new CloudMediaContext(
CloudConfigurationManager.GetSetting("MediaServicesAccountName"),
CloudConfigurationManager.GetSetting("MediaServicesAccountKey"));
foreach (var video in activeJobs)
{
var job = mediaContext.GetJob(video.JobId);
if (job != null)
{
// The video status will be Encoding unless the encoding job is finished or error
video.JobStatus = (job.State == JobState.Finished || job.State == JobState.Error)
? JobStatus.Completed : JobStatus.Encoding;
yield return video;
}
}
}
yield break;
}
开发者ID:NewforceComputerTechnologies,项目名称:MicrosoftAzureTrainingKit,代码行数:26,代码来源:VideoService.cs
示例7: ExportAssetToAzureStorage
public ExportAssetToAzureStorage(CloudMediaContext contextUploadArg, string MediaServicesStorageAccountKeyArg, IAsset sourceAsset, string StorageSuffix)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
MediaServicesStorageAccountKey = MediaServicesStorageAccountKeyArg;
contextUpload = contextUploadArg;
// list asset files ///////////////////////
bool bfileinasset = (sourceAsset.AssetFiles.Count() == 0) ? false : true;
listViewAssetFiles.Items.Clear();
if (bfileinasset)
{
listViewAssetFiles.BeginUpdate();
foreach (IAssetFile file in sourceAsset.AssetFiles)
{
ListViewItem item = new ListViewItem(file.Name, 0);
if (file.IsPrimary) item.ForeColor = Color.Blue;
item.SubItems.Add(file.LastModified.ToLocalTime().ToString("G"));
item.SubItems.Add(AssetInfo.FormatByteSize(file.ContentFileSize));
(listViewAssetFiles.Items.Add(item)).Selected = true;
listassetfiles.Add(file);
}
listViewAssetFiles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
listViewAssetFiles.EndUpdate();
}
myStorageSuffix = StorageSuffix;
}
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:29,代码来源:ExportAssetToAzureStorage.cs
示例8: Main
static int Main(string[] args)
{
if (args.Length != 2)
{
Console.Error.WriteLine("AddFile <AssetId> <filename>, Adds a file to an existing asset");
return -1;
}
string accountName = Environment.GetEnvironmentVariable("ACCOUNT_NAME");
string accountKey = Environment.GetEnvironmentVariable("ACCOUNT_KEY");
CloudMediaContext cloudMediaContext = new CloudMediaContext(accountName, accountKey);
string assetId = args[0];
IAsset asset = cloudMediaContext.FindAssetById(assetId);
string fileName = args[1];
// create the AssetFile with the name as the file being uploaded.
// This is required by the service
var assetFile = asset.AssetFiles.Create(System.IO.Path.GetFileName(fileName));
assetFile.Upload(fileName);
return 0;
}
开发者ID:RobBlackwell,项目名称:MediaServicesCommandLineTools,代码行数:25,代码来源:Program.cs
示例9: DeleteAllAssets
public static void DeleteAllAssets(CloudMediaContext cloudMediaContext)
{
foreach (var asset in cloudMediaContext.Assets)
{
try
{
foreach (var key in asset.ContentKeys)
{
asset.ContentKeys.Remove(key);
}
asset.Update();
}
catch (Exception e)
{
Console.Error.WriteLine("Cant remove content keys for asset {0}, {1}", asset.Id, e);
}
}
foreach (var asset in cloudMediaContext.Assets)
{
try
{
asset.Delete();
}
catch (Exception e)
{
Console.Error.WriteLine("Cant delete asset {0}, {1}", asset.Id, e);
}
}
}
开发者ID:RobBlackwell,项目名称:MediaServicesCommandLineTools,代码行数:33,代码来源:Program.cs
示例10: SendMail
private void SendMail()
{
Setup();
var credentials = new NetworkCredential(mySenGridData.UserName, mySenGridData.Pswd);
// Create the email object first, then add the properties.
SendGridMessage myMessage = new SendGridMessage();
myMessage.AddTo(mySenGridData.To);
myMessage.From = new MailAddress(mySenGridData.FromMail, mySenGridData.FromName);
myMessage.Subject = string.Format("Butler Media Process {0} inctance {1}",myRequest.ProcessTypeId,myRequest.ProcessInstanceId);
_MediaServiceContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
IAsset x = _MediaServiceContext.Assets.Where(xx => xx.Id == myRequest.AssetId).FirstOrDefault();
AssetInfo ai = new AssetInfo(x);
StringBuilder AssetInfoResume = ai.GetStatsTxt();
AssetInfoResume.AppendLine("");
AssetInfoResume.AppendLine("Media Butler Process LOG " + DateTime.Now.ToString());
foreach (string txt in myRequest.Log)
{
AssetInfoResume.AppendLine(txt);
}
AssetInfoResume.AppendLine("-----------------------------");
myMessage.Html = AssetInfoResume.Replace(" ", " ").Replace(Environment.NewLine, "<br />").ToString();
var transportWeb = new Web(credentials);
transportWeb.Deliver(myMessage);
}
开发者ID:pitcrew,项目名称:MediaBlutlerTest01,代码行数:29,代码来源:SendGridStep.cs
示例11: BulkUpload
public BulkUpload(CloudMediaContext context)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
dataGridAssetFiles.DataSource = assetFiles;
_context = context;
}
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:7,代码来源:BulkUpload.cs
示例12: AzureVideoRepository
public AzureVideoRepository(IConfigurationManager configurationManager, IMediaFacade mediaFacade, IAssetFilter assetFilter)
{
this.configurationManager = configurationManager;
this.mediaFacade = mediaFacade;
this.assetFilter = assetFilter;
this.mediaContext = new CloudMediaContext(configurationManager.AccountName, configurationManager.AccountKey);
}
开发者ID:stuartraines,项目名称:Azure.MediaServices.VideoLibrary,代码行数:7,代码来源:AzureVideoRepository.cs
示例13: HandleExecute
public override void HandleExecute(Common.workflow.ChainRequest request)
{
myRequest = (ButlerProcessRequest)request;
Setup();
_MediaServiceContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
IAsset encodedAsset = (from m in _MediaServiceContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();
//Create key
IContentKey key = CreateEnvelopeTypeContentKey(encodedAsset);
//Create Token Template
string tokenTemplateString = AddTokenRestrictedAuthorizationPolicy(key);
Trace.TraceInformation("Added authorization policy: {0}", key.AuthorizationPolicyId);
//create Delivery Policy
CreateAssetDeliveryPolicy(encodedAsset, key);
if (!String.IsNullOrEmpty(tokenTemplateString))
{
// Deserializes a string containing an Xml representation of a TokenRestrictionTemplate
// back into a TokenRestrictionTemplate class instance.
TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer.Deserialize(tokenTemplateString);
// Generate a test token based on the data in the given TokenRestrictionTemplate.
// Note, you need to pass the key id Guid because we specified
// TokenClaim.ContentKeyIdentifierClaim in during the creation of TokenRestrictionTemplate.
Guid rawkey = EncryptionUtils.GetKeyIdAsGuid(key.Id);
string testToken = TokenRestrictionTemplateSerializer.GenerateTestToken(tokenTemplate, null, rawkey);
Trace.TraceInformation("The authorization token is:\n{0}", testToken);
myRequest.Log.Add("The authorization token");
myRequest.Log.Add(testToken);
myRequest.Log.Add("");
}
}
开发者ID:pitcrew,项目名称:MediaBlutlerTest01,代码行数:33,代码来源:EnableAESEncryptionStep.cs
示例14: Main
static void Main(string[] args)
{
// Create and cache the Media Services credentials in a static class variable.
_cachedCredentials = new MediaServicesCredentials(
_mediaServicesAccountName,
_mediaServicesAccountKey);
// Used the cached credentials to create CloudMediaContext.
_context = new CloudMediaContext(_cachedCredentials);
IChannel channel = CreateAndStartChannel();
//IChannel channel = _context.Channels.Where(c => c.Name == "playreadylive").Single();
// Set the Live Encoder to point to the channel's input endpoint:
string ingestUrl = channel.Input.Endpoints.FirstOrDefault().Url.ToString();
// Use the previewEndpoint to preview and verify
// that the input from the encoder is actually reaching the Channel.
string previewEndpoint = channel.Preview.Endpoints.FirstOrDefault().Url.ToString();
// Once you previewed your stream and verified that it is flowing into your Channel,
// you can create an event by creating an Asset, Program, and Streaming Locator.
IProgram program = CreateAndStartProgram(channel);
ILocator locator = CreateLocatorForAsset(program.Asset, program.ArchiveWindowLength);
// IStreamingEndpoint streamingEndpoint = CreateAndStartStreamingEndpoint();
GetLocatorsInAllStreamingEndpoints(program.Asset);
Console.ReadLine();
// Once you are done streaming, clean up your resources.
//Cleanup(streamingEndpoint, channel);
}
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:30,代码来源:Program.cs
示例15: CreateVideoAsync
public async Task<Video> CreateVideoAsync(string title, string description, string name, string type, Stream dataStream)
{
// Create an instance of the CloudMediaContext
var mediaContext = new CloudMediaContext(
CloudConfigurationManager.GetSetting("MediaServicesAccountName"),
CloudConfigurationManager.GetSetting("MediaServicesAccountKey"));
// Create the Media Services asset from the uploaded video
var asset = mediaContext.CreateAssetFromStream(name, title, type, dataStream);
// Get the Media Services asset URL
var videoUrl = mediaContext.GetAssetVideoUrl(asset);
// Launch the smooth streaming encoding job and store its ID
var jobId = mediaContext.ConvertAssetToSmoothStreaming(asset, true);
var video = new Video
{
Title = title,
Description = description,
SourceVideoUrl = videoUrl,
JobId = jobId
};
this.context.Videos.Add(video);
await this.context.SaveChangesAsync();
return video;
}
开发者ID:NewforceComputerTechnologies,项目名称:MicrosoftAzureTrainingKit,代码行数:29,代码来源:VideoService.cs
示例16: Main
static void Main(string[] args)
{
// Create and cache the Media Services credentials in a static class variable.
_cachedCredentials = new MediaServicesCredentials(
_mediaServicesAccountName,
_mediaServicesAccountKey);
// Used the cached credentials to create CloudMediaContext.
_context = new CloudMediaContext(_cachedCredentials);
bool tokenRestriction = false;
string tokenTemplateString = null;
IAsset asset = UploadFileAndCreateAsset(_singleMP4File);
Console.WriteLine("Uploaded asset: {0}", asset.Id);
IAsset encodedAsset = EncodeToAdaptiveBitrateMP4Set(asset);
Console.WriteLine("Encoded asset: {0}", encodedAsset.Id);
IContentKey key = CreateCommonTypeContentKey(encodedAsset);
Console.WriteLine("Created key {0} for the asset {1} ", key.Id, encodedAsset.Id);
Console.WriteLine("PlayReady License Key delivery URL: {0}", key.GetKeyDeliveryUrl(ContentKeyDeliveryType.PlayReadyLicense));
Console.WriteLine();
if (tokenRestriction)
tokenTemplateString = AddTokenRestrictedAuthorizationPolicy(key);
else
AddOpenAuthorizationPolicy(key);
Console.WriteLine("Added authorization policy: {0}", key.AuthorizationPolicyId);
Console.WriteLine();
CreateAssetDeliveryPolicy(encodedAsset, key);
Console.WriteLine("Created asset delivery policy. \n");
Console.WriteLine();
if (tokenRestriction && !String.IsNullOrEmpty(tokenTemplateString))
{
// Deserializes a string containing an Xml representation of a TokenRestrictionTemplate
// back into a TokenRestrictionTemplate class instance.
TokenRestrictionTemplate tokenTemplate =
TokenRestrictionTemplateSerializer.Deserialize(tokenTemplateString);
// Generate a test token based on the the data in the given TokenRestrictionTemplate.
// Note, you need to pass the key id Guid because we specified
// TokenClaim.ContentKeyIdentifierClaim in during the creation of TokenRestrictionTemplate.
Guid rawkey = EncryptionUtils.GetKeyIdAsGuid(key.Id);
string testToken = TokenRestrictionTemplateSerializer.GenerateTestToken(tokenTemplate, null, rawkey, DateTime.UtcNow.AddDays(365));
Console.WriteLine("The authorization token is:\nBearer {0}", testToken);
Console.WriteLine();
}
// You can use the http://smf.cloudapp.net/healthmonitor player
// to test the smoothStreamURL URL.
//
string url = GetStreamingOriginLocator(encodedAsset);
Console.WriteLine("Encrypted Smooth Streaming URL: {0}/manifest", url);
Console.ReadLine();
}
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:60,代码来源:Program.cs
示例17: Encoder
public Encoder(CloudMediaContext context, StorageCredentialsAccountAndKey storageCredentials, MediaEncoding mediaEncoding, TextWriter textWriter)
{
this.context = context;
this.storageCredentials = storageCredentials;
this.MediaEncoding = mediaEncoding;
this.textWriter = textWriter;
}
开发者ID:AppliedIS,项目名称:wams-preview,代码行数:7,代码来源:Encoder.cs
示例18: EncodingAMEPreset
public EncodingAMEPreset(CloudMediaContext context)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
_context = context;
buttonJobOptions.Initialize(_context);
}
开发者ID:shushengli,项目名称:Azure-Media-Services-Explorer,代码行数:7,代码来源:EncodingAMEPreset.cs
示例19: CreateMediaEncodeJob
private static async Task<IJob> CreateMediaEncodeJob(CloudMediaContext context, IAsset assetToEncode)
{
//string encodingPreset = "H264 Broadband 720p";
string encodingPreset = "H264 Smooth Streaming 720p";
IJob job = context.Jobs.Create("Encoding " + assetToEncode.Name + " to " + encodingPreset);
string[] y =
context.MediaProcessors.Where(mp => mp.Name.Equals("Azure Media Encoder"))
.ToArray()
.Select(mp => mp.Version)
.ToArray();
IMediaProcessor latestWameMediaProcessor =
context.MediaProcessors.Where(mp => mp.Name.Equals("Azure Media Encoder"))
.ToArray()
.OrderByDescending(
mp =>
new Version(int.Parse(mp.Version.Split('.', ',')[0]),
int.Parse(mp.Version.Split('.', ',')[1])))
.First();
ITask encodeTask = job.Tasks.AddNew("Encoding", latestWameMediaProcessor, encodingPreset, TaskOptions.None);
encodeTask.InputAssets.Add(assetToEncode);
encodeTask.OutputAssets.AddNew(assetToEncode.Name + " as " + encodingPreset, AssetCreationOptions.None);
job.StateChanged += new EventHandler<JobStateChangedEventArgs>((sender, jsc) => Console.WriteLine(
$"{((IJob) sender).Name}\n State: {jsc.CurrentState}\n Time: {DateTime.UtcNow.ToString(@"yyyy_M_d_hhmmss")}\n\n"));
return await job.SubmitAsync();
}
开发者ID:se02035,项目名称:WEcanHELP,代码行数:30,代码来源:Functions.cs
示例20: ChannelRunOnPremisesEncoder
public ChannelRunOnPremisesEncoder(CloudMediaContext context, IList<IChannel> channels)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
_context = context;
_channels = channels;
}
开发者ID:shushengli,项目名称:Azure-Media-Services-Explorer,代码行数:7,代码来源:ChannelRunOnPremisesEncoder.cs
注:本文中的Microsoft.WindowsAzure.MediaServices.Client.CloudMediaContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论