Example usage for android.media AudioManager STREAM_MUSIC

List of usage examples for android.media AudioManager STREAM_MUSIC

Introduction

In this page you can find the example usage for android.media AudioManager STREAM_MUSIC.

Prototype

int STREAM_MUSIC

To view the source code for android.media AudioManager STREAM_MUSIC.

Click Source Link

Document

Used to identify the volume of audio streams for music playback

Usage

From source file:com.example.android.miwok.activity.ColorsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.word_list);//ww w .  j  a  v a2 s  .c  om

    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    // Create a list of words
    final ArrayList<Word> words = new ArrayList<Word>();
    words.add(new Word("red", "weei", R.drawable.color_red, R.raw.color_red));
    words.add(new Word("mustard yellow", "chiwii", R.drawable.color_mustard_yellow,
            R.raw.color_mustard_yellow));
    words.add(new Word("dusty yellow", "opiis", R.drawable.color_dusty_yellow, R.raw.color_dusty_yellow));
    words.add(new Word("green", "chokokki", R.drawable.color_green, R.raw.color_green));
    words.add(new Word("brown", "akaakki", R.drawable.color_brown, R.raw.color_brown));
    words.add(new Word("gray", "opoppi", R.drawable.color_gray, R.raw.color_gray));
    words.add(new Word("black", "kululli", R.drawable.color_black, R.raw.color_black));
    words.add(new Word("white", "kelelli", R.drawable.color_white, R.raw.color_white));

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    WordAdapter adapter = new WordAdapter(this, words);

    // Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
    // There should be a {@link ListView} with the view ID called list, which is declared in the
    // word_list.xml layout file.
    ListView listView = (ListView) findViewById(R.id.list);
    listView.setBackgroundColor(Color.parseColor("#8800A0"));
    //listView.setBackgroundColor(R.color.category_colors);

    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    listView.setAdapter(adapter);

    //plays the audio for number one when any item in the list is clicked click
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //release current resources being used for media player if it currently exists
            //because we are about to play a different sound file.
            releaseMediaPlayer();

            //get the word located in the list that is at same position as the item clicked in the list
            Word currentWord = words.get(position);

            // Request audio focus for playback
            int result = mAudioManager.requestAudioFocus(mAudioFocusChangeListener,
                    // Use the music stream.
                    AudioManager.STREAM_MUSIC,
                    // Request temporary focus.
                    AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {

                //create the medial player with the audio file that is stored in the list for that word.
                mMediaPlayer = MediaPlayer.create(getApplicationContext(), currentWord.getmMiwokAudio());
                //play the file
                mMediaPlayer.start();

                //listener to stop and release the media player and resources being used
                // once the sounds has finished playing
                mMediaPlayer.setOnCompletionListener(mCompletionListener);
            }

        }
    });
}

From source file:de.tu.darmstadt.seemoo.ansian.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    EventBus.getDefault().register(this);
    super.onCreate(savedInstanceState);
    instance = this;

    // init all prefs
    new Preferences(this);

    // enable logging of demodulated text
    new Logger();

    // TODO: move somewhere more sensible
    new TransmissionChain();

    // Set view for this activity
    setContentView(R.layout.activity_main);

    // ViewPager and its adapters use support library
    // fragments, so use getSupportFragmentManager.
    // Get the ViewPager and set it's PagerAdapter so that it can display
    // items//from w  ww  .jav  a 2s.  c o  m
    viewPager = (MyViewPager) findViewById(R.id.viewpager);
    MainActivityPagerAdapter pagerAdapter = new MainActivityPagerAdapter(getSupportFragmentManager(), viewPager,
            this);
    viewPager.setAdapter(pagerAdapter);
    viewPager.setCurrentItem(1);

    // Make sure the DataHandler instance is created in order for it to catch the new-source-event
    DataHandler.getInstance();

    // Give the SlidingTabLayout the ViewPager
    slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    // Center the tabs in the layout
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(viewPager);
    stateHandler = StateHandler.getInstance();
    stateHandler.start(Preferences.MISC_PREFERENCE.isAutostart());

    // Set the hardware volume keys to work on the music audio stream:
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Start logging if enabled:
    if (Preferences.MISC_PREFERENCE.isLogging()) {
        try {
            File logfile = Preferences.MISC_PREFERENCE.getLogFile();
            logfile.getParentFile().mkdir(); // Create folder
            logcat = Runtime.getRuntime().exec("logcat -f " + logfile);
            Log.i("MainActivity", "onCreate: started logcat (" + logcat.toString() + ") to " + logfile);
        } catch (Exception e) {
            Log.e("MainActivity", "onCreate: Failed to start logging!");
        }
    }

    // Notification
    notification = new AnsianNotification(this);
    // TODO: move that to a better location. only execute when mic is needed
    Log.d(LOGTAG,
            "permission_on_micro=" + ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO));
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[] { Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE },
                0);
    }

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
    }

}

From source file:com.example.android.miwok.activity.PhrasesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.word_list);// w  w  w.j  a  v a 2  s.  co  m

    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    // Create a list of words
    final ArrayList<Word> words = new ArrayList<Word>();
    words.add(new Word("Where are you going?", "minto wuksus", R.raw.phrase_where_are_you_going));
    words.add(new Word("What is your name?", "tinn oyaase'n", R.raw.phrase_what_is_your_name));
    words.add(new Word("My name is...", "oyaaset...", R.raw.phrase_my_name_is));
    words.add(new Word("How are you feeling?", "michkss?", R.raw.phrase_how_are_you_feeling));
    words.add(new Word("Im feeling good.", "kuchi achit", R.raw.phrase_im_feeling_good));
    words.add(new Word("Are you coming?", "ns'aa?", R.raw.phrase_are_you_coming));
    words.add(new Word("Yes, Im coming.", "h nm", R.raw.phrase_yes_im_coming));
    words.add(new Word("Im coming.", "nm", R.raw.phrase_im_coming));
    words.add(new Word("Lets go.", "yoowutis", R.raw.phrase_lets_go));
    words.add(new Word("Come here.", "nni'nem", R.raw.phrase_come_here));

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    WordAdapter adapter = new WordAdapter(this, words);

    // Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
    // There should be a {@link ListView} with the view ID called list, which is declared in the
    // word_list.xml layout file.
    ListView listView = (ListView) findViewById(R.id.list);
    listView.setBackgroundColor(Color.parseColor("#16AFCA"));
    //listView.setBackgroundColor(R.color.category_phrases);

    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    listView.setAdapter(adapter);

    //plays the audio for number one when any item in the list is clicked click
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //release current resources being used for media player if it currently exists
            //because we are about to play a different sound file.
            releaseMediaPlayer();

            //get the word located in the list that is at same position as the item clicked in the list
            Word currentWord = words.get(position);

            /// Request audio focus for playback
            int result = mAudioManager.requestAudioFocus(mAudioFocusChangeListener,
                    // Use the music stream.
                    AudioManager.STREAM_MUSIC,
                    // Request temporary focus.
                    AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {

                //create the medial player with the audio file that is stored in the list for that word.
                mMediaPlayer = MediaPlayer.create(getApplicationContext(), currentWord.getmMiwokAudio());
                //play the file
                mMediaPlayer.start();

                //listener to stop and release the media player and resources being used
                // once the sounds has finished playing
                mMediaPlayer.setOnCompletionListener(mCompletionListener);
            }
        }
    });
}

From source file:net.hyx.app.volumenotification.factory.NotificationFactory.java

private int getStreamFlag(int type) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if ((type == AudioManager.STREAM_MUSIC && settings.getToggleMute())
                || (type == AudioManager.STREAM_RING && settings.getToggleSilent())) {
            return AudioManager.ADJUST_TOGGLE_MUTE;
        }/*from  w w w  .j  a  v  a 2 s .c  o  m*/
    }
    return AudioManager.ADJUST_SAME;
}

From source file:com.ksharkapps.musicnow.ui.activities.BaseActivity.java

/**
 * {@inheritDoc}// w w  w.  j  a v a  2s  . c o m
 */
@Override
protected void onCreate(final Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // Fade it in
    overridePendingTransition(R.anim.swipeback_stack_right_in, R.anim.swipeback_stack_to_back);
    // Control the media volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Bind Apollo's service
    mToken = MusicUtils.bindToService(this, this);

    // Initialize the broadcast receiver
    mPlaybackStatus = new PlaybackStatus(this);

    // Set the layout
    setContentView(setContentView());

    actBar = getSupportActionBar();

    // Initialze the bottom action bar
    initBottomActionBar();

}

From source file:com.example.android.miwok.activity.NumbersActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.word_list);/*from   w w  w  .  j av a2s .c o m*/

    //Create and setup the {@link AudioManager} to request audio focus
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    // Create a list of words
    //made the arraylist final so that it could be accessed inside the onItemClick method.
    final ArrayList<Word> words = new ArrayList<Word>();
    words.add(new Word("one", "lutti", R.drawable.number_one, R.raw.number_one));
    words.add(new Word("two", "otiiko", R.drawable.number_two, R.raw.number_two));
    words.add(new Word("three", "tolookosu", R.drawable.number_three, R.raw.number_three));
    words.add(new Word("four", "oyyisa", R.drawable.number_four, R.raw.number_four));
    words.add(new Word("five", "massokka", R.drawable.number_five, R.raw.number_five));
    words.add(new Word("six", "temmokka", R.drawable.number_six, R.raw.number_six));
    words.add(new Word("seven", "kenekaku", R.drawable.number_seven, R.raw.number_seven));
    words.add(new Word("eight", "kawinta", R.drawable.number_eight, R.raw.number_eight));
    words.add(new Word("nine", "woe", R.drawable.number_nine, R.raw.number_nine));
    words.add(new Word("ten", "naaacha", R.drawable.number_ten, R.raw.number_ten));

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    WordAdapter adapter = new WordAdapter(this, words);

    // Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
    // There should be a {@link ListView} with the view ID called list, which is declared in the
    // word_list.xml layout file.
    ListView listView = (ListView) findViewById(R.id.list);
    //listView.setBackgroundColor(R.color.category_numbers);
    listView.setBackgroundColor(Color.parseColor("#FD8E09"));
    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    listView.setAdapter(adapter);

    //plays the audio for number one when any item in the list is clicked click
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //release current resources being used for media player if it currently exists
            //because we are about to play a different sound file.
            releaseMediaPlayer();

            //get the word located in the list that is at same position as the item clicked in the list
            Word currentWord = words.get(position);

            // Request audio focus for playback
            int result = mAudioManager.requestAudioFocus(mAudioFocusChangeListener,
                    // Use the music stream.
                    AudioManager.STREAM_MUSIC,
                    // Request temporary focus.
                    AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {

                //create the medial player with the audio file that is stored in the list for that word.
                mMediaPlayer = MediaPlayer.create(getApplicationContext(), currentWord.getmMiwokAudio());
                //play the file
                mMediaPlayer.start();

                //listener to stop and release the media player and resources being used
                // once the sounds has finished playing
                mMediaPlayer.setOnCompletionListener(mCompletionListener);
            }

        }
    });

}

From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
    int[] imageViewPosition = savedInstanceState == null ? getIntent().getIntArrayExtra(C.EXTRA_VIEW_POSITION)
            : null;//from   ww  w.  j  a va  2 s .c o  m
    if (!C.API_LOLLIPOP || imageViewPosition == null) {
        overridePendingTransition(R.anim.fast_fade_in, 0);
    }
    applyStatusNavigationTranslucency();
    super.onCreate(savedInstanceState);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    ViewUtils.applyToolbarStyle(this, null);
    expandedScreen = getIntent().getBooleanExtra(C.EXTRA_ALLOW_EXPANDED_SCREEN, false);
    instance.actionBarColor = ACTION_BAR_COLOR;
    boolean obtainImages = getIntent().getBooleanExtra(C.EXTRA_OBTAIN_ITEMS, false);
    ArrayList<GalleryItem> galleryItems = obtainImages ? NavigationUtils.obtainImagesProvider(this) : null;
    String chanName = getIntent().getStringExtra(C.EXTRA_CHAN_NAME);
    Uri uri = getIntent().getData();
    int imagePosition = savedInstanceState != null ? savedInstanceState.getInt(EXTRA_POSITION, -1) : -1;
    if (chanName == null && uri != null) {
        chanName = ChanManager.getInstance().getChanNameByHost(uri.getAuthority());
    }
    ChanLocator locator = null;
    if (chanName != null) {
        locator = ChanLocator.get(chanName);
    }
    threadTitle = getIntent().getStringExtra(C.EXTRA_THREAD_TITLE);
    boolean defaultLocator = false;
    if (locator == null) {
        locator = ChanLocator.getDefault();
        defaultLocator = true;
    }
    if (uri != null && galleryItems == null) {
        galleryItems = new ArrayList<>(1);
        String boardName = null;
        String threadNumber = null;
        if (!defaultLocator) {
            boardName = locator.safe(true).getBoardName(uri);
            threadNumber = locator.safe(true).getThreadNumber(uri);
        }
        galleryItems.add(new GalleryItem(uri, boardName, threadNumber));
        overrideUpButton = true;
        imagePosition = 0;
    } else if (imagePosition == -1) {
        imagePosition = getIntent().getIntExtra(C.EXTRA_IMAGE_INDEX, 0);
    }
    instance.chanName = chanName;
    instance.locator = locator;
    instance.galleryItems = galleryItems;
    allowNavigatePost = getIntent().getBooleanExtra(C.EXTRA_ALLOW_NAVIGATE_POST, false);
    actionBar = findViewById(getResources().getIdentifier("action_bar", "id", "android"));
    rootView = new WindowControlFrameLayout(this);
    rootView.setOnApplyWindowPaddingsListener(this);
    rootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    backgroundDrawable = new GalleryBackgroundDrawable(rootView, C.API_LOLLIPOP ? imageViewPosition : null,
            BACKGROUND_COLOR);
    rootView.setBackground(backgroundDrawable);
    setContentView(rootView);
    if (galleryItems == null || galleryItems.size() == 0) {
        View errorView = getLayoutInflater().inflate(R.layout.widget_error, rootView, false);
        TextView textView = (TextView) errorView.findViewById(R.id.error_text);
        textView.setText(R.string.message_empty_gallery);
        rootView.addView(errorView);
    } else {
        listUnit = new ListUnit(instance);
        pagerUnit = new PagerUnit(instance);
        rootView.addView(listUnit.getListView(), FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.MATCH_PARENT);
        rootView.addView(pagerUnit.getView(), FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.MATCH_PARENT);
        pagerUnit.addAndInitViews(rootView, imagePosition);
        if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_GALLERY_MODE)) {
            galleryMode = savedInstanceState.getBoolean(EXTRA_GALLERY_MODE);
            galleryWindow = savedInstanceState.getBoolean(EXTRA_GALLERY_WINDOW);
            switchMode(galleryMode, false);
            modifySystemUiVisibility(GalleryInstance.FLAG_LOCKED_USER,
                    savedInstanceState.getBoolean(EXTRA_SYSTEM_UI_VISIBILITY));
        } else {
            galleryWindow = imagePosition < 0 || getIntent().getBooleanExtra(C.EXTRA_GALLERY_MODE, false);
            if (galleryWindow && imagePosition >= 0) {
                listUnit.setListSelection(imagePosition, false);
            }
            switchMode(galleryWindow, false);
        }
        pagerUnit.onViewsCreated(imageViewPosition);
    }
}

From source file:com.app.blockydemo.ui.ScriptActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_script);
    ProjectManager projectManager = ProjectManager.getInstance();
    //create project
    try {//from   w  ww. j a  va2s .co m
        projectManager.initializeNewProject("test", this, false);
    } catch (IOException e) {
        e.printStackTrace();
    }
    Sprite sprite = new Sprite("Back");
    projectManager.addSprite(sprite);
    projectManager.setCurrentSprite(sprite);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    currentFragmentPosition = FRAGMENT_SCRIPTS;

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    updateCurrentFragment(currentFragmentPosition, fragmentTransaction);
    fragmentTransaction.commit();

    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);

    buttonAdd = (ImageButton) findViewById(R.id.button_add);
    updateHandleAddButtonClickListener();
}

From source file:com.example.android.bangla.ColorsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.word_list, container, false);

    // Create and setup the AudioManager to request audio focus
    mAudioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);

    // Create a list of words
    final ArrayList<Word> words = new ArrayList<Word>();
    words.add(new Word(R.string.color_red, R.string.bangla_color_red, R.drawable.color_red, R.raw.color_red));
    words.add(new Word(R.string.color_mustard_yellow, R.string.bangla_color_mustard_yellow,
            R.drawable.color_mustard_yellow, R.raw.color_mustard_yellow));
    words.add(new Word(R.string.color_dusty_yellow, R.string.bangla_color_dusty_yellow,
            R.drawable.color_dusty_yellow, R.raw.color_dusty_yellow));
    words.add(new Word(R.string.color_green, R.string.bangla_color_green, R.drawable.color_green,
            R.raw.color_green));/*w ww .  j a  v a 2s . com*/
    words.add(new Word(R.string.color_brown, R.string.bangla_color_brown, R.drawable.color_brown,
            R.raw.color_brown));
    words.add(
            new Word(R.string.color_gray, R.string.bangla_color_gray, R.drawable.color_gray, R.raw.color_gray));
    words.add(new Word(R.string.color_black, R.string.bangla_color_black, R.drawable.color_black,
            R.raw.color_black));
    words.add(new Word(R.string.color_white, R.string.bangla_color_white, R.drawable.color_white,
            R.raw.color_white));

    WordAdapter adapter = new WordAdapter(getActivity(), words, R.color.category_colors);
    ListView listView = (ListView) rootView.findViewById(R.id.list);
    listView.setAdapter(adapter);

    // Set a click listener to play the audio when the list item is clicked on
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            releaseMediaPlayer();
            Word word = words.get(position);
            int result = mAudioManager.requestAudioFocus(mOnAudioFocusChangeListener, AudioManager.STREAM_MUSIC,
                    AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
                mMediaPlayer = MediaPlayer.create(getActivity(), word.getAudioResourceId());
                mMediaPlayer.start();
                mMediaPlayer.setOnCompletionListener(mCompletionListener);
            }
        }
    });

    return rootView;
}

From source file:net.dian1.player.service.PlayerService.java

@Override
public void onCreate() {
    Log.i(Dian1Application.TAG, "Player Service onCreate");

    mPlayerEngine = new PlayerEngineImpl();
    mPlayerEngine.addListener(mLocalEngineListener);

    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN);

    //        mTelephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
    //        mPhoneStateListener = new PhoneStateListener() {
    ///*from   w  w  w  . ja  va 2  s . com*/
    //            @Override
    //            public void onCallStateChanged(int state, String incomingNumber) {
    //                Log.e(Dian1Application.TAG, "onCallStateChanged");
    //                if (state == TelephonyManager.CALL_STATE_IDLE) {
    //                    // resume playback
    //                } else {
    //                    if (mPlayerEngine != null) {
    //                        mPlayerEngine.pause();
    //                    }
    //                }
    //            }
    //
    //        };
    //        mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mWifiLock = mWifiManager.createWifiLock(Dian1Application.TAG);
    mWifiLock.setReferenceCounted(false);

    Dian1Application.getInstance().setConcretePlayerEngine(mPlayerEngine);
    mRemoteEngineListeners = Dian1Application.getInstance().fetchPlayerEngineListener();
}