Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - confused on how you reference an object (mediaplayer)

confused on how you reference an object (mediaplayer)

All your problems with Audio, Video and Images.

confused on how you reference an object (mediaplayer)

Postby jordanstreet » Wed Jul 21, 2010 5:37 am

I just started trying to get into this I have minimal experience in programming like this I mainly do web development so I'm familiar with php, javascript, etc.

Code: Select all
package com.metronome;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;

public class metrnome extends Activity {
   
   MediaPlayer mp = new MediaPlayer();

   /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        this.mp.create(getBaseContext(), R.raw.here_we_go);
    }
   
    public void process (View view)
    {
       this.mp.start();
    }
       
}


I have it set so a button I press calls the process method but it doesn't play. Suggestions?
jordanstreet
Freshman
Freshman
 
Posts: 2
Joined: Wed Jul 21, 2010 5:30 am

Top

Re: confused on how you reference an object (mediaplayer)

Postby blundell » Wed Jul 21, 2010 10:22 am

You can't just call start(), you have to prepare the player and ensure it is in the right state.

Media State

MediaPlayer Example

Code: Select all
public class MediaPlayerDemo_Audio extends Activity {

    private MediaPlayer mMediaPlayer;

@Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setDataSource("somePath/someMedia.ogg");
        mMediaPlayer.prepare();
        mMediaPlayer.start();
    }

@Override
    protected void onDestroy() {
        super.onDestroy();
        if (mMediaPlayer != null) {
            mMediaPlayer.release();
            mMediaPlayer = null;
        }

    }
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests