Esempio n. 1
0
 private void vidPreview_Loaded(object sender, RoutedEventArgs e)
 {
     Core.Initialize();
     lib   = new LibVLC();
     media = new LibVLCSharp.Shared.MediaPlayer(lib);
     vidPreview.MediaPlayer = media;
 }
Esempio n. 2
0
 /// <summary>
 /// Disposes the control.
 /// </summary>
 /// <param name="disposing">The parameter is not used.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         _videoSource?.Dispose();
         _videoSource = null;
         _disposed    = true;
         MediaPlayer  = null;
         CleanUp();
     }
 }
Esempio n. 3
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //this.Hide();
            //this.pic_btn.Visibility = Visibility.Hidden;

            this.clientHeight   = int.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("Height"));
            this.clientWidth    = int.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("Width"));
            this.bottom         = int.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("bottom"));
            this.right          = int.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("right"));
            this.guid           = System.Configuration.ConfigurationManager.AppSettings.Get("guid");
            this.tempPicPath    = AppDomain.CurrentDomain.BaseDirectory + System.Configuration.ConfigurationManager.AppSettings.Get("picPath");
            this.UploadImageURL = System.Configuration.ConfigurationManager.AppSettings.Get("UploadImageURL");
            this.AppKey         = System.Configuration.ConfigurationManager.AppSettings.Get("appKey");
            this.CurrentPhone   = "";

            // 初始化 socket 信息
            this.ServerPath = System.Configuration.ConfigurationManager.AppSettings.Get("ServerPath");

            // 开始监听并处理数据
            //WSocketClient();

            // 在最上层
            this.Topmost = true;

            WindowState = WindowState.Normal;
            ResizeMode  = ResizeMode.NoResize;
            Width       = Screen.AllScreens[0].Bounds.Width;
            Height      = Screen.AllScreens[0].Bounds.Height;
            this.Left   = Width - this.clientWidth - this.right;
            this.Top    = Height - this.clientHeight - this.bottom;
            Width       = this.clientWidth;
            Height      = this.clientHeight;

            // 设置在截图时不在屏幕中显示路径(这个应该是禁止了所以的提示显示)
            List <string> paramsStr = new List <string> {
                "--no-osd", "--no-snapshot-preview"
            };

            _libVLC = new LibVLC(paramsStr.ToArray());
            // 全屏
            _mediaPlayer = new MediaPlayer(_libVLC)
            {
                Fullscreen  = true,
                AspectRatio = this.Width + ":" + (this.Height - 30)
            };

            // 在使用 MediaPlayer 前需要全部加装 VideoView
            //VideoView.Loaded += (s, er) => VideoView.MediaPlayer = _mediaPlayer;
            VideoView.Loaded += LoadedMediaPlayer;

            //AutoStart();
        }
Esempio n. 4
0
        public PlaybackView()
        {
            InitializeComponent();

            Core.Initialize();
            _libVLC                    = new LibVLC();
            MediaPlayer                = new MediaPlayer(_libVLC);
            VideoView.MediaPlayer      = MediaPlayer;
            MediaPlayer.TimeChanged   += (o, args) => Position.Time = args.Time;
            MediaPlayer.LengthChanged += (o, args) => Position.Total = args.Length;

            Loaded += OnLoaded;
        }
Esempio n. 5
0
 /// <summary>
 /// Inicializuje VLC
 /// </summary>
 private void InitializeVlc()
 {
     if (!_libVlcCoreLoaded)
     {
         // Načtení nativní LibVlc - stačí jednou po celý běh aplikace
         Core.Initialize();
         _libVlcCoreLoaded = true;
     }
     _libVlc      = new LibVLC();
     _mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(_libVlc);
     _videoView   = new VideoView {
         MediaPlayer = _mediaPlayer
     };
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            commandBtn.Enabled = false;

            SFSpeechRecognizer.RequestAuthorization((SFSpeechRecognizerAuthorizationStatus auth) =>
            {
                bool buttonIsEnabled = false;
                switch (auth)
                {
                case SFSpeechRecognizerAuthorizationStatus.Authorized:
                    buttonIsEnabled     = true;
                    var node            = audioEngine.InputNode;
                    var recordingFormat = node.GetBusOutputFormat(0);
                    node.InstallTapOnBus(0, 1024, recordingFormat, (AVAudioPcmBuffer buffer, AVAudioTime when) =>
                    {
                        recognitionRequest.Append(buffer);
                    });
                    break;

                case SFSpeechRecognizerAuthorizationStatus.Denied:
                    buttonIsEnabled = false;
                    break;

                case SFSpeechRecognizerAuthorizationStatus.Restricted:
                    buttonIsEnabled = false;
                    break;

                case SFSpeechRecognizerAuthorizationStatus.NotDetermined:
                    buttonIsEnabled = false;
                    break;
                }

                InvokeOnMainThread(() => { commandBtn.Enabled = buttonIsEnabled; });
            });
            _libVLC      = new LibVLC();
            _mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(_libVLC);

            _videoView = new VideoView {
                MediaPlayer = _mediaPlayer
            };

            _videoView.Frame = new CoreGraphics.CGRect(0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height / 2);
            View.AddSubview(_videoView);
            _videoView.MediaPlayer.Play(new Media(_libVLC, VIDEO_URL, FromType.FromLocation));
        }
Esempio n. 7
0
        public void Init(vlc.MediaPlayer player)
        {
            MediaPlayer = player;

            var c = new vlc.MediaPlayer.LibVLCVideoCleanupCb(CleanupCallback);
            var f = new vlc.MediaPlayer.LibVLCVideoFormatCb(VideoFormatCallback);

            MediaPlayer.SetVideoFormatCallbacks(f, c);

            var lv = new vlc.MediaPlayer.LibVLCVideoLockCb(LockVideo);
            var uv = new vlc.MediaPlayer.LibVLCVideoUnlockCb(UnlockVideo);
            var d  = new vlc.MediaPlayer.LibVLCVideoDisplayCb(DisplayVideo);

            MediaPlayer.SetVideoCallbacks(lv, uv, d);

            //we need GC not collect delegates
            _callbacks = new object[] { c, f, lv, uv, d };
        }
Esempio n. 8
0
        public MainWindow()
        {
            InitializeComponent();

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC);

            //VideoView.Loaded += (sender, e) => VideoView.MediaPlayer = _mediaPlayer;
            VideoView.Loaded += (sender, e) => {
                VideoView.MediaPlayer = _mediaPlayer;

                if (!VideoView.MediaPlayer.IsPlaying)
                {
                    VideoView.MediaPlayer.Play(new Media(_libVLC,
                                                         @"FrameTest.mp4", FromType.FromPath));
                }
            };
        }
Esempio n. 9
0
        public Example2()
        {
            InitializeComponent();

            var label = new Label
            {
                Content             = "TEST",
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                Foreground          = new SolidColorBrush(Colors.Red)
            };

            test.Children.Add(label);

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC);

            VideoView.MediaPlayer = _mediaPlayer;
        }
Esempio n. 10
0
        public Example2()
        {
            InitializeComponent();

            var label = new Label
            {
                Content             = "TEST",
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                Foreground          = new SolidColorBrush(Colors.Red)
            };

            test.Children.Add(label);

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC);

            // we need the VideoView to be fully loaded before setting a MediaPlayer on it.
            VideoView.Loaded += (sender, e) => VideoView.MediaPlayer = _mediaPlayer;
        }
Esempio n. 11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = ViewModel.Title;

            AppNameLabel.Text  = "VLCSample";
            VersionLabel.Text  = "1.0";
            AboutTextView.Text = "This app is written in C# and native APIs using the Xamarin Platform. It shares code with its iOS, Android, & Windows versions.";


            _libVLC      = new LibVLC();
            _mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(_libVLC);

            _videoView = new VideoView {
                MediaPlayer = _mediaPlayer
            };

            View = _videoView;

            _videoView.MediaPlayer.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
        }
Esempio n. 12
0
        public MainWindow()
        {
            InitializeComponent();

            /* 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);

            videoURL = getNewUrl();
            Console.WriteLine(videoURL);

            _libVLC           = new LibVLC();
            _mp               = new MediaPlayer(_libVLC);
            videoView.Loaded += (sender, e) => videoView.MediaPlayer = _mp;
            _mp.Play(new Media(_libVLC, videoURL, FromType.FromLocation));
            _mp.Volume       = 30;
            _mp.TimeChanged += TimeChanged;
            _mp.EndReached  += EndReached;

            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;
        }
Esempio n. 13
0
        /// <summary>
        /// 建立新的播放窗口实例
        /// </summary>
        /// <param name="DL">播放对象实例</param>
        /// <param name="默认音量">新建实例的默认音量</param>
        /// <param name="弹幕颜色">新建实例的默认弹幕颜色</param>
        /// <param name="字幕颜色">新建实例的默认字幕颜色</param>
        /// <param name="弹幕大小">新建实例的默认弹幕字体大小</param>
        /// <param name="字幕大小">新建实例的默认字幕字体大小</param>
        /// <param name="宽度">新建实例的默认窗口宽度</param>
        /// <param name="高度">新建实例的默认窗口高度</param>
        public MainWindow(Downloader DL, int 默认音量, SolidColorBrush 弹幕颜色, SolidColorBrush 字幕颜色, int 弹幕大小, int 字幕大小, int 宽度, int 高度)
        {
            InitializeComponent();
            Core.Initialize();
            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC);
            VLCV.Loaded += (sender, e) => VLCV.MediaPlayer = _mediaPlayer;
            this.Width   = 宽度;
            this.Height  = 高度;

            this.Title = DL.DownIofo.标题;
            窗口信息       = new SetWindow.窗口信息()
            {
                GUID = Guid.NewGuid().ToString(),
                X坐标  = this.Left,
                Y坐标  = this.Top,
                宽度   = this.Width,
                高度   = this.Height,
                标题   = this.Title
            };


            窗口是否打开        = true;
            音量.Value      = 默认音量;
            this.Closed  += 关闭窗口事件;
            DD            = DL;
            弹幕框.Opacity   = 0.5;
            字幕.Foreground = 字幕颜色;
            弹幕.Foreground = 弹幕颜色;
            // 字幕.FontSize = 字幕大小;
            字幕.字体大小 = 字幕大小;
            字幕.是否居中 = true;
            //弹幕.FontSize = 弹幕大小;
            弹幕.字体大小            = 弹幕大小;
            DD.DownIofo.文件保存路径 = "./tmp/LiveCache/" + DL.DownIofo.标题 + DL.DownIofo.事件GUID + "_" + 刷新次数 + ".flv";
            DD.DownIofo.继承     = new Downloader.继承();

            设置框.Visibility = Visibility.Collapsed;
            关闭框.Visibility = Visibility.Collapsed;
            if (MMPU.第一次打开播放窗口)
            {
                设置框.Visibility = Visibility.Visible;
                关闭框.Visibility = Visibility.Visible;
                MMPU.第一次打开播放窗口 = false;
            }
            if (MMPU.系统内核版本 != 10)
            {
                弹幕使能                   = false;
                弹幕开关.IsChecked         = false;
                弹幕开关.Visibility        = Visibility.Collapsed;
                字幕使能                   = false;
                字幕开关.IsChecked         = false;
                字幕开关.Visibility        = Visibility.Collapsed;
                修改字幕颜色按钮.Visibility    = Visibility.Collapsed;
                修改弹幕颜色按钮.Visibility    = Visibility.Collapsed;
                弹幕输入窗口.Visibility      = Visibility.Collapsed;
                弹幕发送提示.Visibility      = Visibility.Collapsed;
                弹幕高CPU使用率警告.Visibility = Visibility.Collapsed;
                发送弹幕按钮.Visibility      = Visibility.Collapsed;
                弹幕透明度.Visibility       = Visibility.Collapsed;
                字幕位置.Visibility        = Visibility.Collapsed;
                非win10提示.Visibility    = Visibility.Visible;
            }
            else
            {
                非win10提示.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 14
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;
        }
Esempio n. 15
0
        public VLCMediaPlayer(InputData inputData, ILogger <VLCMediaPlayer> logger)
        {
            this.logger = logger;
            Core.Initialize();
            localFileStreamClient = new Client();
            if (inputData.AttachDebugger)
            {
                vlcArguments.Add("--verbose=2");
            }
            else
            {
                vlcArguments.Add("--verbose=0");
            }

            library      = new LibVLC(vlcArguments.ToArray());
            library.Log += Library_Log;
            mediaPlayer  = new LibVLCSharp.Shared.MediaPlayer(library)
            {
                Hwnd                   = new IntPtr(inputData.Handle),
                EnableKeyInput         = false,
                EnableMouseInput       = false,
                EnableHardwareDecoding = true,
            };
            mediaPlayer.PositionChanged += MediaPlayer_PositionChanged;
            mediaPlayer.EndReached      += (sender, args) =>
            {
                EndReached?.Invoke(this, args);
            };
            mediaPlayer.TimeChanged += (sender, args) =>
            {
                time = args.Time;
                TimeChanged?.Invoke(this, args.Time);

                if (aspectRationSet || mediaPlayer.VideoTrack == -1)
                {
                    return;
                }

                aspectRationSet = true;

                uint  x           = 0;
                uint  y           = 0;
                float aspectRatio = 1;

                if (!mediaPlayer.Size(0, ref x, ref y))
                {
                    return;
                }

                var videoTrack  = mediaPlayer.Media.Tracks.FirstOrDefault(track => track.TrackType == TrackType.Video);
                var orientation = videoTrack.Data.Video.Orientation;

                if (IsFlipped(orientation))
                {
                    aspectRatio = (float)y / x;
                }
                else
                {
                    aspectRatio = (float)x / y;
                }

                if (videoTrack.Data.Video.SarDen != 0)
                {
                    aspectRatio *= (float)videoTrack.Data.Video.SarNum / videoTrack.Data.Video.SarDen;
                }

                VideoInfoChanged?.Invoke(this, new VideoInfo
                {
                    VideoOrientation = orientation.ToString(),
                    AspectRatio      = aspectRatio
                });
            };

            mediaPlayer.LengthChanged += (sender, args) => { if (args.Length > 0)
                                                             {
                                                                 LengthChanged?.Invoke(this, args);
                                                             }
            };
            mediaPlayer.Playing       += (sender, args) => Playing?.Invoke(this, args);
            mediaPlayer.Paused        += (sender, args) => Paused?.Invoke(this, args);
            mediaPlayer.VolumeChanged += (sender, args) => VolumeChanged?.Invoke(this, args);
            mediaPlayer.Unmuted       += (sender, args) => Unmuted?.Invoke(this, args);
            mediaPlayer.Muted         += (sender, args) => Muted?.Invoke(this, args);
        }