Search code examples
c#videotwittertweetinvi

Media could not be played on twitter after posting the video from C# MVC Application


I could successfully post the video(MP4) using the tweetinvi library but the video can not be played after successfully uploading it. Whereas if I post the same video manually it plays just fine. I am unable to find the reason behind it after spending a lot of time on it I'm left with no choice but to request a solution here. Following is the code I use to upload the video on twitter.

 Auth.ApplicationCredentials = new TwitterCredentials(consumerKey, consumerSecret, tokens, tokensecret);
 var vidBytes = System.IO.File.ReadAllBytes(vidPath);
 var videoMedia = Upload.UploadVideo(vidBytes, "video/mp4", "amplify_video");
 var isProcessed = videoMedia.UploadedMediaInfo.ProcessingInfo.State == "succeeded";
 var timeToWait = videoMedia.UploadedMediaInfo.ProcessingInfo.CheckAfterInMilliseconds;

 while (!isProcessed)
 {
     Thread.Sleep(timeToWait);

     // The second parameter (false) informs Tweetinvi that you are manually awaiting the media to be ready
     var mediaStatus = Upload.GetMediaStatus(videoMedia, false);
     isProcessed = mediaStatus.ProcessingInfo.State == "succeeded";
     timeToWait = mediaStatus.ProcessingInfo.CheckAfterInMilliseconds;
 }

 Tweet.PublishTweet(message, new PublishTweetOptionalParameters()
 {
    Medias = 
    {
       videoMedia
    }
 });

I'm using tweetinvi version 1.2.0.1 because my application Framework version restricts me to use the latest version of tweetinvi.


Solution

  • Looks like Twitter Video player doesn't like vsync files. I was creating Vsync Mp4 files for the upload but looks like the Twitter video player can not play vsync video files. This issue has nothing to do with Tweetinvi.