示例#1
0
        public static VlcMedia CreateFromFileDescriptor(VlcInstance instance, int fd)
        {
            VlcMedia m = new VlcMedia();

            m.Handle = LibVlc.libvlc_media_new_fd(instance.Handle, fd);
            return(m);
        }
示例#2
0
        public static VlcMedia CreateFromFilepath(VlcInstance instance, string file)
        {
            VlcMedia m = new VlcMedia();

            m.Handle = LibVlc.libvlc_media_new_path(instance.Handle, file);
            return(m);
        }
示例#3
0
        public static VlcMedia CreateFromUrl(VlcInstance instance, string url)
        {
            VlcMedia m = new VlcMedia();

            m.Handle = LibVlc.libvlc_media_new_location(instance.Handle, url);
            return(m);
        }
示例#4
0
 public VlcMediaPlayer()
 {
     instance             = new VlcInstance();
     Handle               = LibVlc.libvlc_media_player_new(instance.Handle);
     IsKeyInputConsumed   = false;
     IsMouseInputConsumed = false;
     RegisterEvents();
 }
示例#5
0
 public void Dispose()
 {
     DeregisterEvents();
     LibVlc.libvlc_media_player_release(Handle);
     if (instance != null)
     {
         instance.Dispose();
     }
 }
示例#6
0
        private void VideoLengthChanged(IntPtr userdata)
        {
            Length = LibVlc.libvlc_media_player_get_length(this.Handle);

            LengthString = Utils.GetLongTimeAsString(Length);

            if (LengthChanged != null)
            {
                LengthChanged(this, new EventArgs());
            }
        }
示例#7
0
        public void Stop()
        {
            LibVlc.libvlc_media_player_stop(Handle);

            Status = PlayingStatus.STOPPED;

            if (PlayingStatusChanged != null)
            {
                PlayingStatusChanged(this, new PlayingStatusEventArgs(Status));
            }
        }
示例#8
0
        public void Play()
        {
            LibVlc.libvlc_media_player_play(Handle);

            Status = PlayingStatus.PLAYING;

            if (PlayingStatusChanged != null)
            {
                PlayingStatusChanged(this, new PlayingStatusEventArgs(Status));
            }
        }
示例#9
0
 private void RegisterEvents()
 {
     EventManager             = LibVlc.libvlc_media_player_event_manager(Handle);
     vlcLengthChangedDelegate = new LibVlc.EventCallbackDelegate(VideoLengthChanged);
     LibVlc.libvlc_event_attach(EventManager, LibVlc.libvlc_event_type_t.libvlc_MediaPlayerLengthChanged,
                                vlcLengthChangedDelegate, IntPtr.Zero);
     vlcPositionChangedDelegate = new LibVlc.EventCallbackDelegate(VideoPositionChanged);
     LibVlc.libvlc_event_attach(EventManager, LibVlc.libvlc_event_type_t.libvlc_MediaPlayerPositionChanged,
                                vlcPositionChangedDelegate, IntPtr.Zero);
     vlcTimeChangedDelegate = new LibVlc.EventCallbackDelegate(VideoTimeChanged);
     LibVlc.libvlc_event_attach(EventManager, LibVlc.libvlc_event_type_t.libvlc_MediaPlayerTimeChanged,
                                vlcTimeChangedDelegate, IntPtr.Zero);
 }
示例#10
0
        public void Pause()
        {
            if (Status != PlayingStatus.PLAYING)
            {
                return;
            }

            LibVlc.libvlc_media_player_pause(Handle);

            Status = PlayingStatus.PAUSED;

            if (PlayingStatusChanged != null)
            {
                PlayingStatusChanged(this, new PlayingStatusEventArgs(Status));
            }
        }
示例#11
0
 public void Dispose()
 {
     LibVlc.libvlc_media_release(Handle);
 }
示例#12
0
        public void SetVolume(double volume)
        {
            int volumePercent = (int)Math.Round(volume * 100);

            LibVlc.libvlc_audio_set_volume(Handle, volumePercent);
        }
示例#13
0
 public void SetMedia(VlcMedia media)
 {
     LibVlc.libvlc_media_player_set_media(Handle, media.Handle);
 }
示例#14
0
 public VlcMediaPlayer(VlcMedia media)
 {
     Handle               = LibVlc.libvlc_media_player_new_from_media(media.Handle);
     IsKeyInputConsumed   = false;
     IsMouseInputConsumed = false;
 }
示例#15
0
 public VlcInstance()
 {
     Handle = LibVlc.libvlc_new(0, null);
 }