private void testPlayerState(MediaLibraryFactory factory) { PlayerOutput nullOutput = new PlayerOutput(); // string path = GetSampleAudioPath(); if (!System.IO.File.Exists(path)) { Assert.Ignore("The sample file doesn't exists. Ignoring."); } MediaInput input = new MediaInput(MediaInputType.File, path); // using (Player player = factory.CreatePlayer(nullOutput)) { testPlayerState(player, input); } }
/// <summary> /// Initializes VLC resources will be used by control. /// </summary> /// <param name="vlcParameters">Parameters passed to VLC library</param> /// <param name="handler">Callback which can be used to initialize factory instance parameters.</param> /// <exception cref="InvalidOperationException">Reinitialization is not allowed.</exception> /// <exception cref="MediaPlayerException">Media player cannot be initialized.</exception> public void Initialize(ISynchronizeInvoke syncEventsTo, string[] vlcParameters, VlcMediaLibraryFactoryInitHandler handler) { if (isInitialized) { throw new InvalidOperationException("This object does not support multi time initialization."); } // isInitialized = true; initializeFactory(vlcParameters); if (handler != null) { handler(mediaLibraryFactory as VlcMediaLibraryFactory); } // player = mediaLibraryFactory.CreatePlayer(new PlayerOutput(vlcWindowControl.Window)); // Subscribe to events VlcPlayerControlEventsReceiver receiver = new VlcPlayerControlEventsReceiver(this); player.EventsReceivers.Add(new SynchronizedEventsReceiver(syncEventsTo ?? this, receiver, true)); }
/// <summary> /// Initialization of vlclib resources being used by control. /// <see cref="InvalidOperationException"/> will be thrown on re-initialization. /// <see cref="MediaPlayerException"/> may be thrown during initialization VLC subsystem. /// </summary> public void Initialize() { if (isInitialized) { throw new InvalidOperationException("This object does not support multi time initialization."); } // isInitialized = true; // Install VLC packages if necessary VlcDeployment deployment = VlcDeployment.Default; if (!deployment.CheckVlcLibraryExistence(true, false)) { if (logger.IsInfoEnabled) { logger.Info("Unable to find installed vlc library. Starting installing from zip archive."); } deployment.Install(false, true, false, false); if (logger.IsInfoEnabled) { logger.Info("Installed."); } } // VLC objects initialization mediaLibraryFactory = new VlcMediaLibraryFactory(new string[] { "--no-snapshot-preview", "--ignore-config", "--no-osd", "--plugin-path", Path.Combine(getStartupPath(), "plugins") }); player = mediaLibraryFactory.CreatePlayer(new PlayerOutput(vlcWindowControl.Window)); // Subscribe to events VlcPlayerEventsReceiver receiver = new VlcPlayerEventsReceiver(); receiver.EndReached += endReachedEventHandler; receiver.PositionChanged += positionChangedEventHandler; player.EventsReceivers.Add(receiver); }