I'd recommend that you post about this in the .NET client library's
dedicated support group:
https://groups.google.com/group/gdata-dotnet-client-library
Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev
On Mar 14, 11:41 am, garv3 <ga...@gmx.de> wrote:
> I am facing a critical problem. I tried to use the ResumableUploader
> to upload videos to youtube in a chunked way and to resume if the
> connection was lost.
> Uploading works pretty fine but I can not resume any upload. Each time
> I try to resume an upload (no matter if aborted by cancel_async or by
> cutting the connection and waiting for timeout) I get an error stating
> that it is not possible to write into the connection, because it had
> already been opened. What may I do to get it working. By the way: I
> believe I have read about this problem in .Net before...
>
> Here is a snipped of my code:
> [code]
> // start the upload
> ResumableUploader m_ResumableUploader = null;
> Authenticator YouTubeAuthenticator;
>
> m_ResumableUploader = new ResumableUploader(256); //chunksize 256
> kilobyte
> m_ResumableUploader.AsyncOperationCompleted += new
> AsyncOperationCompletedEventHandler(Service_AsyncOperationCompleted);
> m_ResumableUploader.AsyncOperationProgress += new
> AsyncOperationProgressEventHandler(Service_AsyncOperationProgress);
>
> YouTubeAuthenticator = new ClientLoginAuthenticator("YouTube
> Uploader", ServiceNames.YouTube, YTusername, YTpassword);
> YouTubeAuthenticator.DeveloperKey = "my devkey here";
>
> newVideo.MediaSource = new MediaFileSource(videoDateinamen[k],
> MediaFileSource.GetContentTypeForFileName(videoDateinamen[k]));
>
> AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/
> resumable/feeds/api/users/default/uploads");
> link.Rel = ResumableUploader.CreateMediaRelation;
> newVideo.YouTubeEntry.Links.Add(link);
> UploadError = "";
> m_ResumableUploader.InsertAsync(YouTubeAuthenticator,
> newVideo.YouTubeEntry, "inserter");
>
> [...]
>
> // if no progress for some time -> abort and resume
> if (uploadPosition == lastUploadPosition && lastChunk.AddSeconds(20) <
> DateTime.Now)
> {
> // Seit 20 Sekunden kein Fortschritt
> DateTime waitStart = DateTime.Now;
> m_ResumableUploader.CancelAsync(key);
> while (DateTime.Now < waitStart.AddSeconds(310)) // wait for the
> current connection to time out
> {
> statusLabel.Text = "Unterbrochen... " + (310-(DateTime.Now -
> waitStart).Seconds).ToString();
> this.Refresh();
> Application.DoEvents();
> System.Threading.Thread.Sleep(1);
> }
> Stream s = newVideo.MediaSource.GetDataStream();
> s.Seek(uploadPosition, SeekOrigin.Begin); // set position
> m_ResumableUploader = new ResumableUploader(256); //chunksize 256
> kB
> m_ResumableUploader.AsyncOperationCompleted += new
> AsyncOperationCompletedEventHandler(Service_AsyncOperationCompleted);
> m_ResumableUploader.AsyncOperationProgress += new
> AsyncOperationProgressEventHandler(Service_AsyncOperationProgress);
> m_ResumableUploader.ResumeAsync(YouTubeAuthenticator, uploadUri,
> httpVerb, s,
> MediaFileSource.GetContentTypeForFileName(videoDateinamen[k]),
> key); // resume the upload
> MessageBox.Show("Resume:\r\nPosition: " + uploadPosition + "\r\n"
> + uploadUri + "\r\n" + httpVerb + "\r\n" +
> MediaFileSource.GetContentTypeForFileName(videoDateinamen[k]));
> lastChunk = DateTime.Now;
> lastUploadPosition = uploadPosition;}
>
> [/code]
>
> Any suggestions about that? I am really confused and need to get this
> working!
>
> Thanks in advance!
> garv3
--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment