×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Cool How to keep player functionality for my Live TV based Java Midlet project

    I have parsed a url containing images ,names and urls for a java based Live TV App.


    Iam able to show the channel images along with the names. I want to to play the channel video when I click on any channel image.


    How to set or keep video player functionality in my application.



    Code:
       package mypackage;
    
    
    import java.io.*;
    import java.util.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    
    class Channel {    
    	public String cName;    
    	public String cId;    
    	public String cType;
    	public String cLanguage;
    	public String cImage;
    	public String cLink;
    	public String cBandwidth;
    	public String cCellnapid;
    }
    
    class ChannelListHandler extends DefaultHandler {    
    
    	Channel currentChannel;
    	private String lastCharacters;   
    	
    	private Vector channelList;     
    	
    	public ChannelListHandler() {        
    		channelList = new Vector();    
    	}     
    	
    	public Channel[] getChannels() {       
    		Channel[] channels = new Channel[channelList.size()];        
    		channelList.copyInto(channels);        
    		return channels;    
    	}
    	
    	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {    
    		if (qName.equals("channel")) {        
    			currentChannel = new Channel();    
    			}
    		}
    	
    	public void characters(char[] ch, int start, int length) throws SAXException {    
    		lastCharacters = new String(ch, start, length).trim();
    		} 
    	
    	public void endElement(String uri, String localName, String qName) throws SAXException {    
    		if (qName.equals("name")) {        
    			currentChannel.cName=lastCharacters;    		
    		} else if (qName.equals("id")) {        
    			currentChannel.cId=lastCharacters;    		
    		} else if (qName.equals("type")) {        
    			currentChannel.cType=lastCharacters;    		
    		} else if (qName.equals("language")) {        
    			currentChannel.cLanguage=lastCharacters;    		
    		} else if (qName.equals("image")) {        
    			currentChannel.cImage=lastCharacters;    		
    		} else if (qName.equals("link")) {        
    			currentChannel.cLink=lastCharacters;    		
    		} else if (qName.equals("bandwidth")) {        
    			currentChannel.cBandwidth=lastCharacters;    		
    		} else if (qName.equals("cellnapid")) {        
    			currentChannel.cCellnapid=lastCharacters;    
    			channelList.addElement(currentChannel);
    			currentChannel=null;
    		}
    	}	
    }
    
    public class MainMidlet extends MIDlet implements CommandListener, Runnable {     
    	private Form form;     
    	
    	public void startApp() {        
    		if (form == null) {            
    			form = new Form("Demo");            
    			form.addCommand(new Command("Exit", Command.EXIT, 0));            
    			form.setCommandListener(this);             
    			// start parsing            
    			(new Thread(this)).start();        
    			}        
    		Display.getDisplay(this).setCurrent(form);    
    		}     
    	
    	public void pauseApp() {}     
    		
    	public void destroyApp(boolean must) {}     
    	
    	public void commandAction(Command c, Displayable d) {        
    		if (c.getCommandType() == Command.EXIT) {            
    			notifyDestroyed();        
    			}    
    		}  
    	
    	public Image loadImage(String url) throws IOException {
    	    HttpConnection hpc = null;
    	    DataInputStream dis = null;
    	    Image image = null;   
    	    try {
    	      hpc = (HttpConnection) Connector.open(url);
    	      int length = (int) hpc.getLength();
    	      byte[] data = new byte[length];
    	      dis = new DataInputStream(hpc.openInputStream());
    	      dis.readFully(data);	      
    	      try {
    	    	  image = Image.createImage(data, 0, data.length);
    	      } catch (IllegalArgumentException e) {}
    	    } catch (Exception e) {            
    	    } finally {
    	      if (hpc != null) hpc.close();
    	      if (dis != null) dis.close();   
    	    }
    	    return image;
    	}
    	    
    	public void run() {        
    		try {            	
    			ChannelListHandler handler = new ChannelListHandler();                       
    			SAXParser parser = SAXParserFactory.newInstance().newSAXParser();             
    			
    			Channel[] channels = null;
    			HttpConnection con = null;
    			InputStream ins = null;
    			
    			try {
    				con = (HttpConnection)Connector.open("http://yupptv.com/mobile/symbianxmlnew.aspx");
    				ins = con.openInputStream();           
    				parser.parse(ins, handler);
    			 } catch (Exception e) {            
    				 form.append(e.toString());        
    			 }	finally {             		
    				 channels = handler.getChannels(); 
    				 if (con != null) con.close();
    				 if (ins != null) ins.close();
    			 }
    			
    			if (channels != null && channels.length > 0) {
    				for (int i = 0; i < channels.length; i++) {
    					form.append(channels[i].cName);
    					Image image = loadImage(channels[i].cImage);
    					if ( image == null ) form.append("\nInvalid image link!\n");
    					else form.append(new ImageItem(null, image, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER, ""));
    				}
    			} else {               
    				form.append("(no channels)\n");           
    			}
    		} catch (Exception e) {            
    			form.append(e.toString());        
    		}	
    	}
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,569

    Re: How to keep player functionality for my Live TV based Java Midlet project

    If the platform you are targeting, does not support an "embeddable" player component/library, you decode the video stream/formats in your own Java code.

    However, in that case note that it will be difficult (there are many video formats/codecs you need to support), it will be slow (takes time to develop, you cannot take any advantage of built-in/native code or hardware acceleration that the device's native player can do), it will be costly (you have to spend time and effort developing/re-developing and maintaining something that may not be worth your time/investment at all), you will have problems (with your implementation, compatibility, etc., which you might have anyway, but with your own solution you can't blame the device manufacturer).

    In other words, just use whatever APIs the platform provides for launching a built-in/native player and accept that as a fact of life when trying to address this via Java/JME/J2ME.

  3. #3
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Yes Here I have followed

    Code Sample 1: PlayerMIDlet.java given at http://www.oracle.com/technetwork/sy...ex-156363.html which is a simple media player code


    But here i WANT MY CHANEL VIDEO TO PLAY WHEN CLICKED ON IT.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,764

    Re: How to keep player functionality for my Live TV based Java Midlet project

    If you want MMAPI, you may also want to check its specifics to Nokia, http://developer.nokia.com/Resources...media-api.html, things you may find particularly interesting are Content Types (under the class and interface description), and perhaps System properties (under Runtime environment notes).

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,764

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Quote Originally Posted by GTO_India View Post
    But here i WANT MY CHANEL VIDEO TO PLAY WHEN CLICKED ON IT.
    There comes the programming part probably.

  6. #6
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    yes did u checked my code It is asking the User to input the Url instead of directly playing the channel video url directly when clicked on the image icon.


    Thanks

  7. #7
    Registered User
    Join Date
    Aug 2011
    Posts
    39

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Quote Originally Posted by GTO_India View Post
    yes did u checked my code It is asking the User to input the Url instead of directly playing the channel video url directly when clicked on the image icon.

    Thanks
    You need to add that to your code. From the example you linked to, this is the part you are looking for:
    try {
    VideoControl vc;
    defplayer();
    // create a player instance
    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();
    }

  8. #8
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Thank you very much I will update you after checking the code now.

  9. #9
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Yes I have checked your code but still not playing my channel video.

    I dont want to ask the user to ask for the url input but the url video should be played when clicked on the image automatically. pLease try to modify

  10. #10
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    waiting for the quickest reply

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: How to keep player functionality for my Live TV based Java Midlet project

    You wrote on the first message "I have parsed a url containing images ,names and urls for a java based Live TV App."
    So there you go.... you have already parsed for the urls of the videos so use them.
    Video urls can be either RTSP for live streaming or HTTP for VOD streaming, their format should probably be either 3gp or mp4 (and inside encoding can be H.263, H.264, etc.)
    you have to have the direct link to the actual video and not the html page that displays that video.
    If you simply want to be able to react to the user "clicking" on the channel image then add a command to your ImageItem using addCommand and also set its listener with setItemCommandListener and then implement the interface and u got the click event, save a reference to each ImageItem/Command so you can compare which Command was activated (or assign each of the Items a different listener) and that way you exactly which "channel" was clicked and supply the video with the correct URL.
    Heard of DVLUP? Join here

  12. #12
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    yes but Iam not seeing the clicking event as you said.

    Ok I will try to add a command as you have said.

  13. #13
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Please follow my code posted on 2014-01-16, 10:07.


    And please try to put the clickable events so that my channel images when clicked plays the channel video automatically .


    Thanks

  14. #14
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: How to keep player functionality for my Live TV based Java Midlet project

    Please follow the ample assistance and guidance you were given and try to do it yourself.
    Heard of DVLUP? Join here

  15. #15
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,280

    Re: How to keep player functionality for my Live TV based Java Midlet project

    I have rtsp links without 3gp extension like


    rtsp://cdn.m.yuppcdn.net/liveorigin/ndtvhindi900.stream2

    whose codecs info is given as attached here

    Click image for larger version. 

Name:	codec details.jpg 
Views:	291 
Size:	84.5 KB 
ID:	1566
    I have already built a Java Me Midlet project based app for my Live TV application.



    which are the Asha Mobiles which support rtsp protocols as I have seen that


    The rtsp:// protocol is currently not supported on Nokia Asha Platform 1.0 or Nokia Asha Platform 1.1

Similar Threads

  1. Replies: 7
    Last Post: 2013-04-25, 13:09
  2. Live Streaming Player
    By elgringo640 in forum Symbian
    Replies: 29
    Last Post: 2009-06-03, 11:21
  3. Live Streaming Player
    By elgringo640 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2009-05-13, 04:54
  4. Some Carbide functionality lost when importing a project from CVSNT
    By Larsson73 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2009-02-19, 15:13
  5. Is the live test MMSC available to US based developers?
    By bmangino in forum General Messaging
    Replies: 1
    Last Post: 2002-11-25, 07:58

Posting Permissions

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