public TikTokSimplifiedObject(AwemeStructV2 TikTokAwemeStructV2)
        {
            AuthorName = TikTokAwemeStructV2.author.nickname;
            var request = WebRequest.Create(TikTokAwemeStructV2.author.avatar_medium.url_list[0]);

            using (var response = request.GetResponse())
                using (var stream = response.GetResponseStream())
                {
                    if (response.ContentType != "image/webp")
                    {
                        AuthorImage = Convert(System.Drawing.Image.FromStream(stream));
                    }
                    else
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            stream.CopyTo(ms);
                            Bitmap webpConverted = new Imazen.WebP.SimpleDecoder().DecodeFromBytes(ms.ToArray(), ms.Length);
                            AuthorImage = Convert(webpConverted);
                        }
                    }
                }
            LikeNbr    = int.Parse(TikTokAwemeStructV2.statistics.digg_count.ToString());
            CommentNbr = int.Parse(TikTokAwemeStructV2.statistics.comment_count.ToString());
            ShareNbr   = int.Parse(TikTokAwemeStructV2.statistics.share_count.ToString());
            var urlList = TikTokAwemeStructV2.video.play_addr.url_list;

            for (int j = 0; j < 3; j++)
            {
                if (urlList[j].ToString().Contains("api2.musical.ly"))
                {
                    VideoUrl = urlList[j].ToString();
                }
            }
            VideoDesc = makeNiceDesc(TikTokAwemeStructV2.desc);
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();
            volumeTimer  = DateTime.Now;
            volumeThread = new Thread(volumeThreadFunc);
            volumeThread.Start();
            //TikTokLogin.XorEncrypt("password");
            /* Following part is made to get libVLC DLLs, as they are not copied in main folder*/
            var    currentAssembly  = Assembly.GetEntryAssembly();
            var    currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            string VlcLibDirectory  = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")).FullName;

            Core.Initialize(VlcLibDirectory);

            listOfTikTokObj = getNewTikTokObjList();
            AwemeStructV2          newVid = getNextTikTokObj();
            TikTokSimplifiedObject tikTokSimplifiedObject = new TikTokSimplifiedObject(newVid);

            videoURL           = tikTokSimplifiedObject.VideoUrl;
            authorImage.Source = tikTokSimplifiedObject.AuthorImage;
            Console.WriteLine(videoURL);

            _libVLC           = new LibVLC("--verbose=2");
            _mp               = new MediaPlayer(_libVLC);
            videoView.Loaded += (sender, e) => videoView.MediaPlayer = _mp;

            _mp.Volume         = 30;
            volumeSlider.Value = _mp.Volume;

            _mp.Play(new Media(_libVLC, "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", FromType.FromLocation));
            //_mp.Play(new Media(_libVLC, videoURL, FromType.FromLocation));

            _mp.TimeChanged   += TimeChanged;
            _mp.EndReached    += EndReached;
            _mp.VolumeChanged += VolumeChanged;

            PlayImage = new Image();
            var UriStringPlay            = @"pack://*****:*****@"pack://application:,,,/TikTokForWindows;component/Resources/pause-button.png";
            var UriBitmapImageSourcePause = new Uri(UriStringPause, UriKind.Absolute);

            PauseBitmapImage  = new BitmapImage(UriBitmapImageSourcePause);
            PauseImage.Source = PauseBitmapImage;

            LikeImage = new Image();
            var UriStringLike            = @"pack://*****:*****@"pack://application:,,,/TikTokForWindows;component/Resources/notlike-button.png";
            var UriBitmapImageSourceNotLike = new Uri(UriStringNotLike, UriKind.Absolute);

            NotlikeBitmapImage  = new BitmapImage(UriBitmapImageSourceNotLike);
            NotlikeImage.Source = NotlikeBitmapImage;
        }