private void btnUpload_Click(object sender, RoutedEventArgs e)
        {
            //**Clean all this up later**
            var Uploader = new YouTubeFileUploader();
            Uploader.AsyncOperationProgress += new EventHandler<AsyncOperationProgressEventArgs>(Upload_AsyncOperationProgress);
            Uploader.AsyncOperationCompleted += new EventHandler<AsyncOperationCompletedEventArgs>(Upload_AsyncOperationCompleted);

            var uploaderParams = new UploaderParameters(txtLogin.Text, passwordBox1.Password); //especially this

            string filename = String.Format("{0}\\{1}", txtDirectory.Text, textBox1.Text);
            string description = textBox4.Text;
            string title = textBox2.Text;
            var category = new MediaCategory( ((ContentControl)(comboBox1.SelectedItem)).Content.ToString(), YouTubeNameTable.CategorySchema);
            var isVideoPublic = checkBox1.IsChecked;
            var videoFile = new YouTubeFileInfo(filename, title, category, description, isVideoPublic);

            button1.IsEnabled = false; //Disable upload button during an upload
            listVideosView.IsEnabled = false;

            Uploader.UploadFiles(uploaderParams, videoFile);
        }
        private string VideoStatus(string vidId)
        {
            var storedvariables = new StoredVariables();
            var confirm = new UploaderParameters(StoredVariables.Login, StoredVariables.Password);
            var request = confirm.ToYouTubeRequest();

            const string UploadURL = @"http://gdata.youtube.com/feeds/api/videos/";
            var videoEntryUrl = new Uri(UploadURL + vidId);
            try
            {
                var video = request.Retrieve<Google.YouTube.Video>(videoEntryUrl); //Make this Async eventually if possible.
                return video.Status.Reason;
            }
            catch { return null; }
        }
Ejemplo n.º 3
0
        public void UploadFiles(UploaderParameters parameters, YouTubeFileInfo videoFile)
        {
            var request = parameters.ToYouTubeRequest();
            var video = videoFile.ToVideo();

            ((GDataRequestFactory)request.Service.RequestFactory).KeepAlive = true;
            ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999;
            request.Service.AsyncOperationProgress += Service_AsyncOperationProgress;
            request.Service.AsyncOperationCompleted += Service_AsyncOperationCompleted;
            request.Service.InsertAsync(new Uri("http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"), video.AtomEntry, video);
        }