inheritance c# (youtube api)



c#和。net新手我想在Video_details类中创建声明属性,然后我想用来自video_page类的数据填充它们,然后将它们传递到使用数据的Video_upload类,有人能建议我如何这样做吗,通常使用java(我正在创建一个网站,您可以使用youtube data api将视频上传到youtube)

Video_details:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for Video_details
/// </summary>
public class Video_details
{
public Video_details()
{
    //
    // TODO: Add constructor logic here
    //
}
public string vidTitle { get; set; }
public string vidDesc { get; set; }
public string vidTags { get; set; }    
}

Video_page方法代码:

 protected void btnUpload_Click(object sender, EventArgs e)
{
    Video_details vidDetails = new Video_details();

    //get details from textBoxes
    txtTitle.Text = vidDetails.vidTitle.ToString();
    txtDesc.Text = vidDetails.vidDesc.ToString();
    txtTags.Text = vidDetails.vidTags.ToString();


    //lblUploadStatus.Text = "Upload Starting";
    Video_Upload uploadVideo = new Video_Upload();
    new Video_Upload().Run().Wait();
  //  lblVidTitle.Text = "Upload Successful...fat chance thats true";

}

Video_Upload方法代码:

 //VIDEO INFO AND DETAILS
    var video = new Video();
    video.Snippet = new VideoSnippet();
    video.Snippet.Title = Video_details.vidTitle.ToString();
    video.Snippet.Description = "Testing Video Upload";
    video.Snippet.Tags = new string[] { "Test", "Second" };
    video.Snippet.CategoryId = "17";//category id for sport 
    video.Snippet.ChannelId = "UCfvR-wqeoHmAGrHnoQRfs9w";
    video.Status = new VideoStatus();
    video.Status.PrivacyStatus = "public"; // or "private" or "public"
    var filePath = @"C:UserssiobhanDocumentsVisual Studio 2015WebSitesFYP_NovemberIMG_6638.mp4"; // Replace with path to actual movie file.

你似乎把事情做错了。在View_page中,您必须从文本框中填写Video_details的属性:

vidDetails.vidTitle = txtTitle.Text;
...

那么Video_Upload类必须有一个接受Video_details类型参数的Upload方法

public class Video_upload
{
    public void Upload(Video_details video)
    {
        //TODO: upload the data here
    }
}

有了这个类,你可以像这样上传

uploadVideo.Upload(vidDetails);

对于异步上传,请查看MSDN上使用async和await (c#)进行异步编程。

相关内容

  • 没有找到相关文章

最新更新