Esempio n. 1
0
        public VLCPlayer(int width, int height, string mediaUrl, bool audio)
        {
            Debug.Log("Playing: " + mediaUrl);
            _width  = width;
            _height = height;

            _gcHandle = GCHandle.Alloc(this);

            string argstrings = _defaultArgs;

            if (!audio)
            {
                argstrings += ";--no-audio";
            }

            string[] args = argstrings.Split(';');

            _libvlc = LibVLCWrapper.libvlc_new(args.Length, args);

            if (_libvlc == IntPtr.Zero)
            {
                Debug.LogError("Failed loading new libvlc instance...");
                return;
            }

            _media = LibVLCWrapper.libvlc_media_new_location(_libvlc, mediaUrl);

            if (_media == IntPtr.Zero)
            {
                Debug.LogError("For some reason media is null, maybe typo in the URL?");
                return;
            }

            _mediaPlayer = LibVLCWrapper.libvlc_media_player_new(_libvlc);
            LibVLCWrapper.libvlc_media_player_set_media(_mediaPlayer, _media);

            _lockHandle    = vlc_lock;
            _unlockHandle  = vlc_unlock;
            _displayHandle = vlc_picture;

            LibVLCWrapper.libvlc_video_set_callbacks(_mediaPlayer, _lockHandle, _unlockHandle, _displayHandle, GCHandle.ToIntPtr(_gcHandle));
            LibVLCWrapper.libvlc_video_set_format(_mediaPlayer, "RV24", (uint)_width, (uint)_height, (uint)_width * (uint)_channels);
            LibVLCWrapper.libvlc_media_player_play(_mediaPlayer);

            System.Threading.Thread t = new System.Threading.Thread(TrackReaderThread);
            t.Start();
        }
Esempio n. 2
0
 internal static extern void libvlc_video_set_callbacks(IntPtr mediaPlayer, LockCB _lock, UnlockCB _unlock, DisplayCB _display, IntPtr _opaque);