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

	if !s.running {
		if err := s.init(); err != nil {
			logger.Error(err)
			return err
		}

		go func() {
			logger.Info("Starting DLNA")
			if err := s.server.Serve(); err != nil {
				logger.Error(err)
			}
		}()
		s.running = true

		if s.startTimer != nil {
			s.startTimer.Stop()
			s.startTimer = nil
			s.startTime = nil
		}
	}

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

		if s.stopTimer == nil {
			s.stopTimer = time.AfterFunc(*duration, func() {
				s.Stop(nil)
			})
			t := time.Now().Add(*duration)
			s.stopTime = &t
		}
	}

	return nil
}
// Start starts the DLNA service. If duration is provided, then the service
// is stopped after the duration has elapsed.
Start starts the DLNA service. If duration is provided, then the service
is stopped after the duration has elapsed.
// Start starts the DLNA service . If duration is provided then the service // is stopped after the duration has elapsed .
func (s *Service) Start(duration *time.Duration) error {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if !s.running {
		if err := s.init(); err != nil {
			logger.Error(err)
			return err
		}
		go func() {
			logger.Info("Starting DLNA")
			if err := s.server.Serve(); err != nil {
				logger.Error(err)
			}
		}()
		s.running = true
		if s.startTimer != nil {
			s.startTimer.Stop()
			s.startTimer = nil
			s.startTime = nil
		}
	}
	if duration != nil {
		if s.stopTimer != nil {
			s.stopTimer.Stop()
			s.stopTime = nil
		}
		if s.stopTimer == nil {
			s.stopTimer = time.AfterFunc(*duration, func() {
				s.Stop(nil)
			})
			t := time.Now().Add(*duration)
			s.stopTime = &t
		}
	}
	return nil
}
func ( s * Service ) Start ( duration * time . Duration ) error { s . mutex . Lock ( ) defer s . mutex . Unlock ( ) if ! s . running { if err := s . init ( ) ; err != nil { logger . Error ( err ) return err } go func ( ) { logger . Info ( " " ) if err := s . server . Serve ( ) ; err != nil { logger . Error ( err ) } } ( ) s . running = true if s . startTimer != nil { s . startTimer . Stop ( ) s . startTimer = nil s . startTime = nil } } if duration != nil { if s . stopTimer != nil { s . stopTimer . Stop ( ) s . stopTime = nil } if s . stopTimer == nil { s . stopTimer = time . AfterFunc ( * duration , func ( ) { s . Stop ( nil ) } ) t := time . Now ( ) . Add ( * duration ) s . stopTime = & t } } return nil }
Start starts the DLNA service.
Start starts the DLNA service .
// clear the existing stop timer