
from libavg import avg, app
import sys

class VideoPlayer(app.MainDiv):
    def init(self):
        self.videoNode = avg.VideoNode(
                href=sys.argv[1],
                parent=self)
        self.videoNode.play()
        
app.App().run(VideoPlayer(), app_resolution='1920x1080', app_window_size='720x450')


from libavg import avg, app
import sys

class VideoPlayer(app.MainDiv):

    def onArgvParserCreated(self, parser):
        parser.set_usage("%prog <video>")

    def onArgvParsed(self, options, args, parser):
        if len(args) != 1:
            parser.print_help()
            sys.exit(1)

        self.__dir=args[0]

    def onInit(self):
        self.videoNode = avg.VideoNode(
                href=self.__dir,
                size=(500, 500),
                parent=self)
        self.videoNode.play()
        
app.App().run(VideoPlayer(), app_resolution='1920x1080', app_window_size='720x450')

Add checks for script parameters and correct onInit name
Add checks for script parameters and correct onInit name

  
  from libavg import avg, app
  import sys
  
  class VideoPlayer(app.MainDiv):
+ 
+     def onArgvParserCreated(self, parser):
+         parser.set_usage("%prog <video>")
+ 
+     def onArgvParsed(self, options, args, parser):
+         if len(args) != 1:
+             parser.print_help()
+             sys.exit(1)
+ 
+         self.__dir=args[0]
+ 
-     def init(self):
+     def onInit(self):
          self.videoNode = avg.VideoNode(
-                 href=sys.argv[1],
+                 href=self.__dir,
+                 size=(500, 500),
                  parent=self)
          self.videoNode.play()
          
  app.App().run(VideoPlayer(), app_resolution='1920x1080', app_window_size='720x450')
  
Add checks for script parameters and correct onInit name
## Code Before:

from libavg import avg, app
import sys

class VideoPlayer(app.MainDiv):
    def init(self):
        self.videoNode = avg.VideoNode(
                href=sys.argv[1],
                parent=self)
        self.videoNode.play()
        
app.App().run(VideoPlayer(), app_resolution='1920x1080', app_window_size='720x450')

## Instruction:
Add checks for script parameters and correct onInit name
## Code After:

from libavg import avg, app
import sys

class VideoPlayer(app.MainDiv):

    def onArgvParserCreated(self, parser):
        parser.set_usage("%prog <video>")

    def onArgvParsed(self, options, args, parser):
        if len(args) != 1:
            parser.print_help()
            sys.exit(1)

        self.__dir=args[0]

    def onInit(self):
        self.videoNode = avg.VideoNode(
                href=self.__dir,
                size=(500, 500),
                parent=self)
        self.videoNode.play()
        
app.App().run(VideoPlayer(), app_resolution='1920x1080', app_window_size='720x450')
