Ejemplo n.º 1
0
        protected async void StartupCheck()
        {
            //Check if any removable drives are currently mounted
            var tasks = DriveInfo.GetDrives().Where(driveInfo => driveInfo.DriveType == DriveType.CDRom || driveInfo.DriveType == DriveType.Removable).
                        Select(driveInfo => Task.Run(() => ExamineVolume(driveInfo.Name)));
            await Task.WhenAll(tasks);

            PlayItemsModel.AddOrUpdateRemovableMediaItems(_removableMediaItems.Values.SelectMany(i => i));
        }
Ejemplo n.º 2
0
 void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
 {
     if (message.ChannelName == RemovableMediaMessaging.CHANNEL)
     {
         RemovableMediaMessaging.MessageType messageType = (RemovableMediaMessaging.MessageType)message.MessageType;
         if (messageType == RemovableMediaMessaging.MessageType.MediaInserted)
         {
             string drive = (string)message.MessageData[RemovableMediaMessaging.DRIVE_LETTER];
             var    type  = ExamineVolume(drive);
             if (_removableMediaItems.TryGetValue(drive, out var items))
             {
                 PlayItemsModel.AddOrUpdateRemovableMediaItems(items);
             }
             RemovableMediaManagerSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <RemovableMediaManagerSettings>();
             if (settings.AutoPlay == AutoPlayType.AutoPlay)
             {
                 IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
                 if (!pcm.IsFullscreenContentWorkflowStateActive)
                 {
                     CheckAutoPlay(drive, type);
                 }
             }
         }
         else if (messageType == RemovableMediaMessaging.MessageType.MediaRemoved)
         {
             string drive = (string)message.MessageData[RemovableMediaMessaging.DRIVE_LETTER];
             IEnumerable <MediaItem> items;
             if (_removableMediaItems.TryRemove(drive, out items))
             {
                 PlayItemsModel.RemoveRemovableMediaItems(items);
             }
             if (_removableMediaItems.TryRemove(drive + @"\", out items))
             {
                 PlayItemsModel.RemoveRemovableMediaItems(items);
             }
         }
     }
     else if (message.ChannelName == ServerConnectionMessaging.CHANNEL)
     {
         ServerConnectionMessaging.MessageType messageType = (ServerConnectionMessaging.MessageType)message.MessageType;
         if (messageType == ServerConnectionMessaging.MessageType.HomeServerConnected && _runStartupCheck)
         {
             _runStartupCheck = false;
             StartupCheck();
         }
     }
 }