content: 
  ' Dr33MTV Video Player Component
  ' Enhanced video player with AI-driven recommendations
  
  sub init()
      print "VideoPlayer: Initializing..."
      
      ' Configure video player
      m.top.enableTrickPlay = true
      m.top.enableUI = true
      
      ' Observe playback events
      m.top.observeField("position", "onPositionChanged")
      m.top.observeField("state", "onStateChanged")
  end sub
  
  sub onPositionChanged()
      ' Update playback position for analytics
      m.top.playbackPosition = m.top.position
      
      ' Trigger AI recommendations at 25%, 50%, 75% of video
      if m.top.duration > 0
          progress = m.top.position / m.top.duration
          
          if progress >= 0.25 and progress < 0.26
              requestAIRecommendations("quarter")
          else if progress >= 0.50 and progress < 0.51
              requestAIRecommendations("half")
          else if progress >= 0.75 and progress < 0.76
              requestAIRecommendations("three_quarter")
          end if
      end if
  end sub
  
  sub onStateChanged()
      state = m.top.state
      print "VideoPlayer: State changed to: " + state
      
      if state = "playing"
          ' Video started playing - request initial recommendations
          requestAIRecommendations("start")
      else if state = "finished"
          ' Video finished - request next content recommendations
          requestAIRecommendations("finished")
      end if
  end sub
  
  sub requestAIRecommendations(trigger as string)
      print "VideoPlayer: Requesting AI recommendations for trigger: " + trigger
      
      ' Create recommendation task
      if m.recommendationTask = invalid
          m.recommendationTask = CreateObject("roSGNode", "RecommendationTask")
          m.recommendationTask.observeField("recommendations", "onRecommendationsReceived")
      end if
      
      ' Set current content context for AI
      if m.top.content <> invalid
          m.recommendationTask.currentContent = m.top.content
          m.recommendationTask.trigger = trigger
          m.recommendationTask.control = "RUN"
      end if
  end sub
  
  sub onRecommendationsReceived()
      print "VideoPlayer: AI recommendations received"
      
      if m.recommendationTask.recommendations <> invalid
          m.top.aiRecommendations = m.recommendationTask.recommendations
      end if
  end sub
  