danielagaba 0 Junior Poster in Training

hi

i have a piece code for a midlet that plays videos. Since it is not being streamed, i know the video file is first downloaded before it is played. When i try it on an actual device using gprs, i cannot tell whether the file is actually being downloaded or not . can someone help me with an explanation and if possible a sample code that will help show the size of the file and its download status. part of the code for the player is below.

public void run() {
      play(getURL());
   }

   String getURL() { 
	location = "http://127.0.0.1/Test/";
     return location+url.getString()+".3gp";
   }

   void play(String url) {
      try {
		 
         VideoControl vc;
         defplayer();
         // create a player instance
		// Alert alert = new Alert("Loading. Please wait ....");
      //alert.setTimeout(Alert.FOREVER);
      //display.setCurrent(alert);

         player = Manager.createPlayer(url);
         player.addPlayerListener(this);
         // realize the player
         player.realize();
         vc = (VideoControl)player.getControl(
		   "VideoControl");
		  
         if(vc != null) {
            Item video = (Item)vc.initDisplayMode(
			  vc.USE_GUI_PRIMITIVE, null);
            Form v = new Form("Playing Video...");
            StringItem si = new StringItem("Status: ", 
			  "Playing...");
            v.append(si);
            v.append(video);
            display.setCurrent(v);
         }
		 
         player.prefetch();
         player.start();
      }
      catch(Throwable t) {
         reset();
      }
   }

   void defplayer() throws MediaException {
      if (player != null) {
		 
         if(player.getState() == Player.STARTED) {
            player.stop();
         }
         if(player.getState() == Player.PREFETCHED) {
			 
            player.deallocate();
         }
         if(player.getState() == Player.REALIZED || 
		    player.getState() == Player.UNREALIZED) {
			
            player.close();
         }
      }
      player = null;
   }

   void reset() {
      player = null;
   }

   void stopPlayer() {
      try {
         defplayer();
      } 
      catch(MediaException me) {
      }
      reset();
   }

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.