Search code examples
androidandroid-serviceandroid-notificationsandroid-music-player

android music player with service


i am looking for a basic implementation of an android music player for learning purpose. All i want is a music player with service and oncompletionlistener that would move to the next track and a notification. but i havent yet been able to find anything like that. any help will be appreciated. thanks in advance.


Solution

  • try this code

    VideoView videoView = (VideoView)findViewById(R.id.myvideoview);
    
                 videoView.setOnCompletionListener(this);//checks when end
    
                 File path = new File(mPath + "/" + "your file name");
    
                 videoView.setVideoPath(path.getAbsolutePath());
                 MediaController mediaController = new MediaController(this);
                 mediaController.setMediaPlayer(videoView);
                 mediaController.setAnchorView(videoView);
    
                 videoView.setMediaController(mediaController);
                 videoView.requestFocus();
                 videoView.start();
    

    for more see this http://www.vogella.de/articles/AndroidMedia/article.html