You Are Here:

Community: Developer Discussion Boards

#1 Old [Moved] Problem In Video For S60 Series - 2008-04-17, 07:37

Join Date: Apr 2008
Posts: 2
amitsrivastava
Offline
Registered User
Hello
I want to write a application through which i can play the video,problem is in player.getControle("VideoControle") it is giving me the value null ,so plz tell me how to resolve this problem ,my code is below plz have a look

Thanks


Code:
import java.util.Hashtable;
import java.util.Enumeration;
import java.io.*;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.media.Player;
import javax.microedition.media.Manager;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.control.VideoControl;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.midlet.*;

public class MediaMIDlet extends MIDlet
  implements CommandListener, PlayerListener {

  public Display display=null;
  private List itemList=null;
  private Form form=null;

  private Command stopCommand;
  private Command pauseCommand;
  private Command startCommand;

  private Hashtable items;
  private Hashtable itemsInfo;

   Player player;
  private VideoControl vc;
  
  
  Item video;

  public MediaMIDlet() {
    display = Display.getDisplay(this);
       
      // creates an item list to let you select multimedia files to play
    itemList = new List("Select an item to play", List.IMPLICIT);

    // stop, pause and restart commands
    stopCommand = new Command("Stop", Command.STOP, 1);
    pauseCommand = new Command("Pause", Command.ITEM, 1);
    startCommand = new Command("Start", Command.ITEM, 1);

    // a form to display when items are being played
    form = new Form("Playing media");

    // the form acts as the interface to stop and pause the media
    form.addCommand(stopCommand);
    form.addCommand(pauseCommand);
    form.setCommandListener(this);
    
    display.setCurrent(form);
    // create a hashtable of items
    items = new Hashtable();

    // and a hashtable to hold information about them
    itemsInfo = new Hashtable();

       
  items.put("Video from jar", "file://bark.3gp");
  itemsInfo.put("Video from jar", "Video/3gpp");
  
  
  }

  public void startApp() {

    // when MIDlet is started, use the item list to display elements
    for(Enumeration en = items.keys(); en.hasMoreElements();) {
    itemList.append((String)en.nextElement(), null);
  }

    itemList.setCommandListener(this);

    // show the list when MIDlet is started
    display.setCurrent(itemList);
  }

  public void pauseApp() {
    // pause the player
    try {
      if(player != null) player.stop();
    } catch(Exception e) {}
  }

  public void destroyApp(boolean unconditional) {
    if(player != null) player.close(); // close the player
  }

  public void commandAction(Command command, Displayable disp) {

    // generic command handler

    // if list is displayed, the user wants to play the item
    if(disp instanceof List) {
      List list = ((List)disp);

      String key = list.getString(list.getSelectedIndex());

      // try and play the selected file
      try {
        playMedia((String)items.get(key), key);
      } catch (Exception e) {
        System.err.println("Unable to play: " + e);
        e.printStackTrace();
      }
    } else if(disp instanceof Form) {

      // if showing form, means the media is being played
      // and the user is trying to stop or pause the player
      try {

        if(command == stopCommand) { // if stopping the media play

          player.close(); // close the player
          display.setCurrent(itemList); // redisplay the list of media
          form.removeCommand(startCommand); // remove the start command
          form.addCommand(pauseCommand); // add the pause command

        } else if(command == pauseCommand) { // if pausing

          player.stop(); // pauses the media, note that it is called stop
          form.removeCommand(pauseCommand); // remove the pause command
          form.addCommand(startCommand); // add the start (restart) command
        } else if(command == startCommand) { // if restarting

          player.start(); // starts from where the last pause was called
          form.removeCommand(startCommand);
          form.addCommand(pauseCommand);
        }
      } catch(Exception e) {
        System.err.println(e);
      }
    }

  }

  /* Creates Player and plays media for the first time */
  private void playMedia(String locator, String key) throws Exception {

    // locate the actual file, we are only dealing
    // with file based media here
    
    // create the player
    // loading it as a resource and using information about it
    
                 
    
    InputStream is = getClass().getResourceAsStream("/bark.3gp");   
    player = Manager.createPlayer(is,"Video/3gpp");
     
    // a listener to handle player events like starting, closing etc
    player.addPlayerListener(this);
    player.realize(); // realize
    
    player.setLoopCount(-1); // play indefinitely
    display.setCurrent(form);
    player.prefetch(); // prefetch
    player.start();
    
       
  }

  /* Handle player events */
public void playerUpdate(Player player, String event, Object eventData) {

    // if the event is that the player has started, show the form
	// but only if the event data indicates that the event relates to newly
	// stated player, as the STARTED event is fired even if a player is
	// restarted. Note that eventData indicates the time at which the start
	// event is fired.
	if(event.equals(PlayerListener.STARTED) ) {

        // see if we can show a video control, depending on whether the media
		// is a video or not
		VideoControl vc = null;
		if((vc = (VideoControl)player.getControl("VideoControl")) != null) {
		  Item videoDisp =
			(Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null);
		  form.append(videoDisp);
               
		}

	        
            //display.setCurrent(form);
	} else if(event.equals(PlayerListener.CLOSED)) {

	  form.deleteAll(); // clears the form of any previous controls
	}
  }
}
Last edited by ltomuta : 2008-04-17 at 07:55. Reason: Please use [code][/code] tags
Reply With Quote

#2 Old Re: Problem In Video For S60 Series - 2008-04-17, 07:54

Join Date: Sep 2004
Posts: 7,953
Location: Tampere, Finland
ltomuta's Avatar
ltomuta
Offline
Forum Nokia Expert
Feedback to Series 40 does not equal in any way to support for Series 40. Please post to the appropriate forum if you really expect somebody to answer to you in a timely fashion.
Reply With Quote

#3 Old Re: [Moved] Problem In Video For S60 Series - 2008-04-17, 19:57

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
Which device are you talking about?

Hartti
Reply With Quote

#4 Old Re: [Moved] Problem In Video For S60 Series - 2008-04-18, 13:20

Join Date: Apr 2008
Posts: 2
amitsrivastava
Offline
Registered User
hi hartti

I am using S60 developer tools and trying to run it on its emulator, and i also tried this on Nokia N73 ,but it is not working there also .But when i used the same code on sprint emulator ,i found that it is working fine ,plz tell me what is the problem.
sorry for late Response and Thanks for your interest .
Regards
amit
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
S60 3rd Edition SDK for MIDP problem playing video suffix Mobile Java Tools & SDKs 7 2007-04-27 05:35
Http Connection problem with Series 40 devices madhavis Mobile Java General 0 2005-01-21 07:01
Problem in NewL() of CVideoPlayerUtility (series 60 2.0 SDK) mishrasaurabh General Symbian C++ 1 2004-12-31 14:08
Problem with Series 90 & internet ManishPatil General Symbian C++ 1 2004-04-08 12:55
Series 60 Symbian 1.2.1 and socket open problem lobz Mobile Java Tools & SDKs 0 2003-08-24 16:17

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ