regarding playing mpeg4 & h.264 video file in android player

by root » Fri, 13 Feb 2009 18:16:15 GMT


Sponsored Links
 hi,
i have h.264&mp4 video file i am using following code but its giving
ioexception if any one know what is problem pls help me out.also there
is no folder called /raw in /res directory but some one written that we
need to place our video file in raw directory.can v place it any where
in file system & give path.

package org.anddev.android.musicplayer;
import java.io.*;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MusicPlayer extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
       
        // Find the Button from the xml-file.
        Button cmd_play = (Button)this.findViewById(R.id.cmd_play);
        cmd_play.setOnClickListener(new OnClickListener(){

               //@Override
               public void onClick(View arg0) {
                                        
                 
            MediaPlayer mp = new MediaPlayer();
                                   
            mp.setDataSource("/home/bugsbunny1.m4v");                           
                           
                mp.prepare();                                   
                                                                          
mp.start();                           
                  
// i.e. react on the end of the music-file:

                    mp.setOnCompletionListener(new
OnCompletionListener(){

                         // @Override
                         public void onCompletion(MediaPlayer arg0) {
                              // File has ended !!! Wink
                         }
                    });
               }
        });
    }
}                                  
                    
                                        
                                                
                                        
                  
                  
                  


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--~--~---------~--~----~------------~-------~--~----~



regarding playing mpeg4 & h.264 video file in android player

by Roman Romano » Fri, 13 Feb 2009 19:40:02 GMT


 why don't you just create a file called 'raw' in the 'res' folder????




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


regarding playing mpeg4 & h.264 video file in android player

by root » Fri, 13 Feb 2009 20:22:33 GMT


 i tried that but it didn't worked for me.





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--~--~---------~--~----~------------~-------~--~----~



regarding playing mpeg4 & h.264 video file in android player

by Dave Sparks » Sat, 14 Feb 2009 07:13:26 GMT


 he res directory inside your source tree does not equate to a
directory on the device. It's just a convention for telling the aapt
compiler what resources need to be included in the APK. Anything you
put in the res directory ends up zipped up inside the APK file along
with the Java code.

If you want to play from a resource file, use the MediaPlayer factory
function:

MediaPlayer mp = MediaPlayer.create(context, R.raw.bugsbunny1);
mp.start();

In your sample code, you use:

setDataSource("/home/bugsbunny1.m4v");

I can only guess this means you are trying to play the file from your
home directory on your host system. This will not work because the
emulator is running its own kernel and has its own file system. You
need to copy your file to the emulated SD card image using adb push
command.

On Feb 13, 4:24 am, root <gurur...@sarayusoftech.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Adding items to ListView dynamically

Hello,

I have a ListView (ListViewContacts) and another ListView
(ContactList).

When I click on a Button in ListViewContacts I get ContactList, when I
select/click a contact in ContactList, this contact is added to the
list in ListViewContacts.

This scenario above is what I would like to achieve, though I haven't
found the right way to do this.

This is the onListItemClick code for ContactList, this starts the
Activity ListViewContact and also gives the clicked contact:

protected void onListItemClick(ListView l, View v, int position, long
id) {
          super.onListItemClick(l, v, position, id);
          Intent intent = new Intent(ContactList.this,
BlablaActivity.class);
          Uri person = ContentUris.withAppendedId(People.CONTENT_URI,
id);
          intent.setData(person);
          startActivity(intent);
     }


This is part of the onCreate() from ListViewContacts, this retrieves
the contact from ContactList and adds it to the ListView:

if(getIntent().getData() != null) {
               Uri data = getIntent().getData();

               Cursor addedContactCursor = getContentResolver().query
(data, null, null, null, null);
               startManagingCursor(addedContactCursor);
               String[] name = new String[]{People.NAME,
People.NUMBER};
               int[] to = new int[]{R.id.nametext, R.id.numbertext};
               adapter = new SimpleCursorAdapter
(this,R.layout.contact_row, addedContactCursor, name, to);
               ListView listView =  (ListView) findViewById
(R.id.addedcontactslist);
               listView.setAdapter(adapter);
          }


The problem here is that only 1 contact is added to the list each
time, which is the last one that has been clicked on within the
ContactList. The code speaks for it self. I assume this happens
because a new SimpleCursorAdapter is initiated every time.

What is the best way of adding these contacts, so that the
ListViewContacts keeps remembering all contacts and not only the last
one that is added? Thanks in advace.
--~--~---------~--~----~------------~-------~--~----~

2. data access

Hi,

How do I access the data of an intent that has already been performed.
For example, I sent a text message and now I want to retrieve the
contents
of that message (subject, body, recipient) or the time the message
was sent, or similar....

any suggestion is appreciated

thx in advance

--~--~---------~--~----~------------~-------~--~----~

3. Detecting Noise

4. When to setResult for onActivityResult

5. Can I add a custom qualifier to resource directory?

6. aapt ERROR

7. Need an on-device exception viewer