コード例 #1
2
        public override bool Play(string strFile)
        {
            url = strFile;

            VlcContext.StartupOptions.IgnoreConfig = true;
            VlcContext.StartupOptions.AddOption("--no-video-title-show");
            VlcContext.StartupOptions.AddOption("--http-caching=" + OnlineVideos.MediaPortal1.PluginConfiguration.Instance.wmpbuffer);
            //VlcContext.StartupOptions.LogOptions.LogInFile = true;
            //VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Standard;
            //VlcContext.StartupOptions.LogOptions.LogInFilePath = Path.Combine(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Log), "vlc-onlinevideos.log");
            if (IsInstalled)
            {
                VlcContext.LibVlcDllsPath = vlcPath;
                VlcContext.LibVlcPluginsPath = Path.Combine(vlcPath, "plugins");
            }

            vlcCtrl = new VlcControl();
            GUIGraphicsContext.form.Controls.Add(vlcCtrl);
            vlcCtrl.Enabled = false;

            vlcCtrl.PositionChanged += vlcCtrl_PositionChanged;
            vlcCtrl.EncounteredError += vlcCtrl_EncounteredError;

            media = new PathMedia(strFile);

            vlcCtrl.Play(media);

            GUIPropertyManager.SetProperty("#TV.Record.percent3", 0.0f.ToString()); // set to 0, as this player doesn't support download progress reporting

            GUIWaitCursor.Init(); GUIWaitCursor.Show(); // init and show the wait cursor while buffering

            return true;
        }
コード例 #2
0
 public void Preview()
 {
     if (!string.IsNullOrEmpty(this.File))
     {
         MediaBase media = new PathMedia(File);
         media.ParsedChanged+=media_ParsedChanged;
         myVlcControl.AudioProperties.IsMute = true;
         myVlcControl.AudioProperties.Volume = 0;
         myVlcControl.Media = media;
         myVlcControl.Play();
     }
 }      
コード例 #3
0
ファイル: VlcPlayer.cs プロジェクト: ch4/vlcdotnet
        /// <summary>
        /// Initializes a new instance of the <see cref="VlcPlayer"/> class.
        /// </summary>
        /// <remarks>
        /// Making changes to the Form sometimes adds the following line of code to VlcPlayer.Designer.cs:
        ///    this.vlcControl.Media = null;
        /// As the Media property may not be set to null in the current release, this will raise an exception at 
        /// runtime. So, if you get an <see cref="ArgumentNullException"/> in VlcControl.Common.cs, check for this
        /// line of code and remove it. 
        /// </remarks>
        public VlcPlayer()
        {
            InitializeComponent();

            labelPlaybackPosition.Text = string.Empty;
            this.vlcControl.PositionChanged += this.VlcControlOnPositionChanged;

            /* 
            var media = new LocationMedia("screen://");
            vlcControl1.SetMedia(media);
            */

            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                var media = new PathMedia(openFileDialog.FileName);
                vlcControl.Media = media;
            }
        }
コード例 #4
0
ファイル: MediaBase.cs プロジェクト: windygu/mp-onlinevideos2
        private void OnVlcEvent(ref LibVlcEventArgs eventData, IntPtr userData)
        {
            switch (eventData.Type)
            {
            case EventTypes.MediaDurationChanged:
                EventsHelper.RaiseEvent(DurationChanged, this, new VlcEventArgs <long>(eventData.MediaDurationChanged.NewDuration));
                break;

            case EventTypes.MediaFreed:
                EventsHelper.RaiseEvent(Freed, this, new VlcEventArgs <EventArgs>(EventArgs.Empty));
                break;

            case EventTypes.MediaMetaChanged:
                EventsHelper.RaiseEvent(MetaChanged, this, new VlcEventArgs <Metadatas>(eventData.MediaMetaChanged.MetaType));
                break;

            case EventTypes.MediaParsedChanged:
                EventsHelper.RaiseEvent(ParsedChanged, this, new VlcEventArgs <int>(eventData.MediaParsedChanged.NewStatus));
                break;

            case EventTypes.MediaStateChanged:
                EventsHelper.RaiseEvent(StateChanged, this, new VlcEventArgs <States>(eventData.MediaStateChanged.NewState));
                break;

            //TODO
            case EventTypes.MediaSubItemAdded:
                MediaBase media;
                if (this is LocationMedia)
                {
                    media = new LocationMedia(eventData.MediaSubitemAdded.NewChild);
                }
                else
                {
                    media = new PathMedia(eventData.MediaSubitemAdded.NewChild);
                }
                EventsHelper.RaiseEvent(MediaSubItemAdded, this, new VlcEventArgs <MediaBase>(media));
                break;
            }
        }
コード例 #5
0
 private void OnVlcEvent(ref LibVlcEventArgs eventData, IntPtr userData)
 {
     switch (eventData.Type)
     {
         case EventTypes.MediaDurationChanged:
             EventsHelper.RaiseEvent(DurationChanged, this, new VlcEventArgs<long>(eventData.MediaDurationChanged.NewDuration));
             break;
         case EventTypes.MediaFreed:
             EventsHelper.RaiseEvent(Freed, this, new VlcEventArgs<EventArgs>(EventArgs.Empty));
             break;
         case EventTypes.MediaMetaChanged:
             EventsHelper.RaiseEvent(MetaChanged, this, new VlcEventArgs<Metadatas>(eventData.MediaMetaChanged.MetaType));
             break;
         case EventTypes.MediaParsedChanged:
             EventsHelper.RaiseEvent(ParsedChanged, this, new VlcEventArgs<int>(eventData.MediaParsedChanged.NewStatus));
             break;
         case EventTypes.MediaStateChanged:
             EventsHelper.RaiseEvent(StateChanged, this, new VlcEventArgs<States>(eventData.MediaStateChanged.NewState));
             break;
         //TODO
         case EventTypes.MediaSubItemAdded:
             MediaBase media;
             if (this is LocationMedia)
                 media = new LocationMedia(eventData.MediaSubitemAdded.NewChild);
             else
                 media = new PathMedia(eventData.MediaSubitemAdded.NewChild);
             EventsHelper.RaiseEvent(MediaSubItemAdded, this, new VlcEventArgs<MediaBase>(media));
             break;
     }
 }
コード例 #6
0
 private void previewChannelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ListViewItem item = channelList.SelectedItems[0];
         if (item == null)
             return;
         splitContainer2.Panel2Collapsed = false;
         Channel c = (Channel)item.Tag;
         TuneToChannel(c);
         if (vlcControl1.Media != null) vlcControl1.Media.Dispose();
         MediaBase media = new PathMedia(string.Format("rtp://@{0}", GetLocalIP() + ":500" + tuner));
         vlcControl1.Media = media;
         vlcControl1.Play();
     }
     catch (Exception ex)
     {
         Log("Failed to start internal preview for the channel: " + ex.Message);
     }
 }
コード例 #7
0
 private void PlayMedia(Code.Media.MediaData m)
 {
     if (m.LocalFile != null)
     {
         PathMedia media = new PathMedia(m.LocalFile.FullName);
         media.ParsedChanged += MediaOnParsedChanged;
         myVlcControl.Media = media;
         myVlcControl.Position = this.Position;
     }
     else
     {
         LocationMedia media = m.LocationMedia;
         media.ParsedChanged += MediaOnParsedChanged;
         myVlcControl.Media = media;
     }
     myVlcControl.Play();
 }
コード例 #8
0
    protected override void OnKeyDown(KeyEventArgs e)
    {
      if (e.Key == Key.Q)
      {
        VlcContext.CloseAll();

        Application.Current.Shutdown();
      }
      if (e.Key == Key.Escape)
      {
        popMenu();
      }

      if (e.Key == Key.Enter)
      {
        if (curMenu.List.SelectedItem == null)
        {
          return;
        }
        MenuEntry item = (MenuEntry)curMenu.List.SelectedItem;
        if (item.Item is Song)
        {
          Song a = (item.Item as Song);
          if (myVlcControl.Medias.Any())
          {
            myVlcControl.Medias.RemoveAt(0);
            myVlcControl.Stop();
          }
          var file = new PathMedia(a.Path);
          myVlcControl.Play(file);

          showNowPlayingBar();
          artistName.Text = a.Artist.Name;
          songName.Text = a.Title;
        }
        if (item.Item is Artist)
        {
          Artist a = (item.Item as Artist);
          var albumMenu = new ListMenu(a.Name, albumsMenu);
          var albums = a.Albums.ToList(); 
          albums.ForEach(x =>
          {
            var s = new MenuEntry(x.Name);
            s.Item = x;
            albumMenu.Items.Add(s);
          });    
          pushMenu(albumMenu);
        }
        if (item.Item is Album)
        {
          Album a = (item.Item as Album);
          var songMenu = new ListMenu(a.Name, songsMenu);
          var songs = a.Songs.ToList();
          songs.ForEach(x =>
          {
            var s = new MenuEntry(x.Title);
            s.Item = x;
            songMenu.Items.Add(s);
          });           
          pushMenu(songMenu);
        }
      }
      base.OnKeyDown(e);
    }