本文整理汇总了C#中System.Video类的典型用法代码示例。如果您正苦于以下问题:C# Video类的具体用法?C# Video怎么用?C# Video使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Video类属于System命名空间,在下文中一共展示了Video类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertOrUpdateVideo
public void InsertOrUpdateVideo(Video video)
{
_context.Entry(video).State = video.VideoID == 0 ? EntityState.Added : EntityState.Modified;
foreach (var videoAsset in video.Assets)
_context.Entry(videoAsset).State = videoAsset.VideoAssetID == 0 ? EntityState.Added : EntityState.Modified;
_context.SaveChanges();
}
示例2: AddToMyFavorites
public bool AddToMyFavorites(Video i_Video)
{
bool exsit = false;
if (i_Video != null)
{
if (MyFavoritesVideos.Count > 0)
{
foreach (Video currentVideo in MyFavoritesVideos)
{
if (currentVideo.VideoId == i_Video.VideoId)
{
exsit = true;
break;
}
}
}
}
else
{
throw new ArgumentNullException("You must choose video!");
}
if (!exsit)
{
MyFavoritesVideos.Add(i_Video);
}
return exsit;
}
示例3: upload
public async Task<ActionResult> upload()
{
var youtubeService = await GetYouTubeService();
var channels = youtubeService.Channels.List("");
var video = new Video();
// video.Snippet.
video.Snippet = new VideoSnippet();
video.Snippet.ChannelId = channels.Id;
video.Snippet.Title = "Monica Video";
video.Snippet.Description = "Monica Video Description";
video.Snippet.Tags = new string[] { "monica", "vidzapper", "The Assetry" };
video.Snippet.CategoryId = "22"; // See https://developers.google.com/youtube/v3/docs/videoCategories/list
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "unlisted"; // or "private" or "public"
var filePath = Server.MapPath("~/App_Data/monica.mp4");// @"REPLACE_ME.mp4"; // Replace with path to actual movie file.
using (var fileStream = new FileStream(filePath, FileMode.Open))
{
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
var tmp = await videosInsertRequest.UploadAsync();
Console.Write(tmp.BytesSent);
}
return View();
}
示例4: Run
public async Task Run(Stream fileStream)
{
string CLIENT_ID = "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"; // Replace with your client id
string CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxx"; // Replace with your secret
var youtubeService = AuthenticateOauth(CLIENT_ID, CLIENT_SECRET, "SingleUser");
var video = new Video();
video.Snippet = new VideoSnippet();
video.Snippet.Title = "Default Video Title " + new Guid();
video.Snippet.Description = "Default Video Description";
video.Snippet.Tags = new string[] { "tag1", "tag2" };
video.Snippet.CategoryId = "22";
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "unlisted"; // or "private" or "public"
const int KB = 0x400;
var minimumChunkSize = 50 * KB;
using (fileStream)
{
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
videosInsertRequest.ChunkSize = minimumChunkSize * 8;
await videosInsertRequest.UploadAsync();
}
}
示例5: Encode
public void Encode(Video video)
{
// Video encoding logic
foreach (var channel in _notificationChannels)
channel.Send(new Message());
}
示例6: BtPickVideoClick
private async void BtPickVideoClick(object sender, RoutedEventArgs e)
{
App app = Application.Current as App;
if (app == null)
return;
FileOpenPicker openPicker = new FileOpenPicker
{
ViewMode = PickerViewMode.Thumbnail,
SuggestedStartLocation = PickerLocationId.VideosLibrary
};
openPicker.FileTypeFilter.Add(".avi");
openPicker.FileTypeFilter.Add(".mp4");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);
Video video = new Video { Title = file.DisplayName, Tags = file.DisplayName, Synopse = file.DisplayName };
this.tblock_PostVideoResult.Text = await client.CreateVideoAsync(file, video);
}
else
{
this.tblock_PostVideoResult.Text = "Error reading file";
}
}
示例7: btn_upload_Click
private void btn_upload_Click(object sender, RoutedEventArgs e)
{
btn_upload.IsEnabled = false;
btn_upload.Content = "Uploading";
btn_cancel.IsEnabled = true;
uploadVideo = new Video();
uploadVideo.Title = txt_title.Text.ToString();
uploadVideo.Description = txt_description.Text.ToString();
uploadVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
uploadVideo.Keywords = txt_keywords.Text.ToString();
if (cb_privacy.SelectedIndex == 1)
{
uploadVideo.Private = true;
}
else
{
uploadVideo.Private = false;
}
uploadVideo.YouTubeEntry.MediaSource = new MediaFileSource(txt_video_path.Text.ToString(), getMimeType(txt_video_path.Text.ToString()));
bw = new BackgroundWorker();
bw.WorkerSupportsCancellation = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
if (bw.IsBusy != true)
{
bw.RunWorkerAsync();
}
}
示例8: search
public async static void search(string query)
{
using(WebClient c = new WebClient())
{
c.Headers.Add("Content-Type", "application/json");
var requestUri = new Uri(string.Format("{0}/search?part=snippet&q={1}&maxResults=50&key={2}&type=video&videoCategoryId=10", API_ENDPOINT, query, API_KEY));
var json = await c.DownloadStringTaskAsync(requestUri);
var jsonObject = JsonConvert.DeserializeObject<YouTubeResponse>(json);
videos.Clear();
foreach(var videoResult in jsonObject.items)
{
var video = new Video();
video.title = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(videoResult.snippet.title));
video.id = videoResult.id.videoId;
video.date = videoResult.snippet.publishedAt;
if (video.isValid())
{
videos.Add(video);
}
}
}
}
示例9: configSource_browseBtn_Click
private void configSource_browseBtn_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.CheckFileExists = true;
ofd.CheckPathExists = true;
ofd.Multiselect = false;
// TODO: Filter extensions to video exclusively
if (ofd.ShowDialog() == DialogResult.OK)
{
configSource_browsePath.Text = ofd.FileName;
FileName = ofd.FileName;
StartFrame = 0;
vid = new Video(FileName); // TODO: What if exception here?
EndFrame = vid.CountFrames() - 1;
SetupTextboxValidation();
configSource_startFrame.Value = 0;
configSource_endFrame.Value = EndFrame;
SetStartFramePreview((int)configSource_startFrame.Value);
SetEndFramePreview((int)configSource_endFrame.Value);
configSource_startFrame.Enabled = true;
configSource_endFrame.Enabled = true;
}
}
示例10: GetVideoPage
/// <summary>動画へアクセスするページを取得する</summary>
/// <param name="Target">ターゲット動画</param>
public VideoPage GetVideoPage(Video.VideoInfo Target)
{
if (Target.videoPage != null)
return Target.videoPage;
else
return Target.videoPage = new VideoPage(Target, this, context);
}
示例11: Create
public static FullVideo Create(Google.YouTube.Video ytVideo = null)
{
if (ytVideo == null) {
throw new Exception("Invalid link");
}
CurtDevDataContext db = new CurtDevDataContext();
Video new_video = new Video {
embed_link = ytVideo.VideoId,
title = ytVideo.Title,
screenshot = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[2].Url : "/Content/img/noimage.jpg",
description = ytVideo.Description,
watchpage = ytVideo.WatchPage.ToString(),
youtubeID = ytVideo.VideoId,
dateAdded = DateTime.Now,
sort = (db.Videos.Count() == 0) ? 1 : db.Videos.OrderByDescending(x => x.sort).Select(x => x.sort).First() + 1
};
db.Videos.InsertOnSubmit(new_video);
db.SubmitChanges();
FullVideo fullvideo = new FullVideo {
videoID = new_video.videoID,
embed_link = new_video.embed_link,
dateAdded = new_video.dateAdded,
sort = new_video.sort,
videoTitle = new_video.title,
thumb = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[0].Url : "/Content/img/noimage.jpg"
};
return fullvideo;
}
示例12: Create_Click
protected void Create_Click(object sender, EventArgs e)
{
var playlist = new Playlist()
{
Title = this.Server.HtmlEncode(this.TitleTextBox.Text),
Description = this.Server.HtmlEncode(this.Description.Text),
CreationDate = DateTime.UtcNow,
CreatorId = this.User.Identity.GetUserId()
};
Video video = this.Videos.GetByUrl(this.Server.HtmlEncode(this.Url.Text));
if (video == null)
{
video = new Video()
{
Url = this.Server.HtmlEncode(this.Url.Text)
};
}
Category category = this.Categories.All().Where(c => c.Name == this.CategorySelect.SelectedItem.Text).FirstOrDefault();
playlist.Category = category;
playlist.Videos.Add(video);
this.Playlists.Create(playlist);
this.Playlists.SaveChanges();
}
示例13: DeleteVideo
public void DeleteVideo(int videoID)
{
var video = new Video() { VideoID = videoID };
_context.Videos.Attach(video);
_context.Videos.Remove(video);
_context.SaveChanges();
}
示例14: Tutorial_Load
private void Tutorial_Load(object sender, EventArgs e)
{
int height = pnlTV.Height;
int width = pnlTV.Width;
try
{
video = new Video(System.IO.Path.Combine(Application.StartupPath, "RaagaHacker.avi"), false);
video.Owner = pnlTV;
pnlTV.Width = width;
pnlTV.Height = height;
video.Play();
}
catch (Exception ex)
{
frmException frm = new frmException();
frm.ExceptionDialogTitle = "Tutorial_Load: Uanble to play video ";
frm.ErrorMessage = ex.Message;
frm.StrackTrace = ex.StackTrace;
if (frm.ShowDialog() == DialogResult.OK)
{
frm.Dispose();
frm = null;
}
}
finally
{
if (video != null)
{
video.Dispose();
video = null;
}
}
}
示例15: BBuscador
protected void BBuscador(String track)
{
string spotUrl = String.Format("http://ws.spotify.com/search/1/track?q={0}", track);
WebClient spotService = new WebClient();
spotService.Encoding = Encoding.UTF8;
spotService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(SpotService_DownloadTracksCompleted);
spotService.DownloadStringAsync(new Uri(spotUrl));
YouTubeRequest request = new YouTubeRequest(settings);
YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
query.OrderBy = "relevance";
query.Query = track;
query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
Feed<Video> videoFeed = request.Get<Video>(query);
if (videoFeed.Entries.Count() > 0)
{
video1 = videoFeed.Entries.ElementAt(0);
literal1.Text = String.Format(embed, video1.VideoId);
if (videoFeed.Entries.Count() > 1)
{
video1 = videoFeed.Entries.ElementAt(1);
literal1.Text += String.Format(embed, video1.VideoId);
}
}
}