Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi i am using YouTube API v3

below is code : https://developers.google.com/youtube/v3/code_samples/dotnet?hl=en#upload_a_video[^]

below is way to get videoid...

void videosInsertRequest_ResponseReceived(Video video)
{
string videoId = video.Id;
}

i want to return this video id to my variable, how can i do that.

Thanks in advanced.
Posted
Comments
CHill60 24-Dec-15 7:24am    
You have returned it to a variable - string videoId - what is the problem?
Member 11324668 24-Dec-15 7:30am    
videosInsertRequest_ResponseReceived is void type we can not convert this to string type.
CHill60 24-Dec-15 7:40am    
videosInsertRequest_ResponseReceived is indeed a method returning a void, however the parameter passed into it is of type Video which appears to have a property Id. You could try string videoId = video.Id.ToString():
Member 11324668 24-Dec-15 7:51am    
thank you for reply,
my question is after get videoId, how can i return this videoid to my function.

using (var fileStream = new FileStream(filePath, FileMode.Open))
{
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");

videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;

var aa = videosInsertRequest.ResponseBody;

await videosInsertRequest.UploadAsync();
}

because of after complete videosInsertRequest_ResponseReceived method, i am not able to get inserted vidoid back.

i want this videoid, so i can update into the database.. but problem is we can not able to pass other parameter on method 'videosInsertRequest_ResponseReceived' or not able to return inserted videoid.
Herman<T>.Instance 24-Dec-15 8:00am    
Is this asynchronous? In that case you should use a delegate to have the value available in other parts of your program

1 solution

I solve issue by below code..
ideosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived => SomeFunc(videosInsertRequest_ResponseReceived);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900