func (s *Service) Stop(duration *time.Duration) {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	if s.running {
		logger.Info("Stopping DLNA")
		err := s.server.Close()
		if err != nil {
			logger.Error(err)
		}
		s.running = false

		if s.stopTimer != nil {
			s.stopTimer.Stop()
			s.stopTimer = nil
			s.stopTime = nil
		}
	}

	if duration != nil {
		// clear the existing stop timer
		if s.startTimer != nil {
			s.startTimer.Stop()
		}

		if s.startTimer == nil {
			s.startTimer = time.AfterFunc(*duration, func() {
				if err := s.Start(nil); err != nil {
					logger.Warnf("error restarting DLNA server: %v", err)
				}
			})
			t := time.Now().Add(*duration)
			s.startTime = &t
		}
	}
}
// Stop stops the DLNA service. If duration is provided, then the service
// is started after the duration has elapsed.
Stop stops the DLNA service. If duration is provided, then the service
is started after the duration has elapsed.
// Stop stops the DLNA service . If duration is provided then the service // is started after the duration has elapsed .
func (s *Service) Stop(duration *time.Duration) {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if s.running {
		logger.Info("Stopping DLNA")
		err := s.server.Close()
		if err != nil {
			logger.Error(err)
		}
		s.running = false
		if s.stopTimer != nil {
			s.stopTimer.Stop()
			s.stopTimer = nil
			s.stopTime = nil
		}
	}
	if duration != nil {
		if s.startTimer != nil {
			s.startTimer.Stop()
		}
		if s.startTimer == nil {
			s.startTimer = time.AfterFunc(*duration, func() {
				if err := s.Start(nil); err != nil {
					logger.Warnf("error restarting DLNA server: %v", err)
				}
			})
			t := time.Now().Add(*duration)
			s.startTime = &t
		}
	}
}
func ( s * Service ) Stop ( duration * time . Duration ) { s . mutex . Lock ( ) defer s . mutex . Unlock ( ) if s . running { logger . Info ( " " ) err := s . server . Close ( ) if err != nil { logger . Error ( err ) } s . running = false if s . stopTimer != nil { s . stopTimer . Stop ( ) s . stopTimer = nil s . stopTime = nil } } if duration != nil { if s . startTimer != nil { s . startTimer . Stop ( ) } if s . startTimer == nil { s . startTimer = time . AfterFunc ( * duration , func ( ) { if err := s . Start ( nil ) ; err != nil { logger . Warnf ( " " , err ) } } ) t := time . Now ( ) . Add ( * duration ) s . startTime = & t } } }
Stop stops the DLNA service.
Stop stops the DLNA service .
// clear the existing stop timer