انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
پیلر آنلاین موزیک

پیلر آنلاین موزیک

#2
خودم پیداش کردم.
کسی خواست استفاده کنه یا ادمین عزیز به عنوان کلید بذارتش تو سایت Shy 

کد پی‌اچ‌پی:
import java.io.IOException;

import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.Toast;

public class 
MusicAndroidActivity extends Activity {

    static 
MediaPlayer mPlayer;
    
Button buttonPlay;
    
Button buttonStop;
    
String url "http://آدرس سایت آپلود موزیکmusic.mp3";
 
   private    SeekBar seekbar;
 
   
    Handler handler
;
    
Runnable runnable;
 
   
    
@Override
    
public void onCreate(Bundle savedInstanceState) {
        
super.onCreate(savedInstanceState);
        
setContentView(R.layout.main);
        
        
seekbar = (SeekBarfindViewById(R.id.seekBar);
        
        
buttonPlay = (ButtonfindViewById(R.id.play);
        
buttonPlay.setOnClickListener(new OnClickListener() {
            
            
            public 
void onClick(View v) {
                
mPlayer = new MediaPlayer();
                
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
                try {
                    
mPlayer.setDataSource(url);
                } catch (
IllegalArgumentException e) {
                    
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!"Toast.LENGTH_LONG).show();
                } catch (
SecurityException e) {
                    
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!"Toast.LENGTH_LONG).show();
                } catch (
IllegalStateException e) {
                    
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!"Toast.LENGTH_LONG).show();
                } catch (
IOException e) {
                    
e.printStackTrace();
                }
                try {
                    
mPlayer.prepare();
                } catch (
IllegalStateException e) {
                    
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!"Toast.LENGTH_LONG).show();
                } catch (
IOException e) {
                    
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!"Toast.LENGTH_LONG).show();
                }
                
mPlayer.start();
            }
        });
        
        
buttonStop = (ButtonfindViewById(R.id.stop);
        
buttonStop.setOnClickListener(new OnClickListener() {

            public 
void onClick(View v) {
                
// TODO Auto-generated method stub
                
if(mPlayer!=null && mPlayer.isPlaying()){
                    
mPlayer.stop();
                }
            }
        });
        
        
        
    }
    
    protected 
void onDestroy() {
        
super.onDestroy();
        
// TODO Auto-generated method stub
        
if (mPlayer != null) {
            
mPlayer.release();
            
mPlayer null;
        }
    }


پاسخ
 سپاس شده توسط yasi ، شماره مجازی امارات


پیام‌های این موضوع
پیلر آنلاین موزیک - توسط shahramm - ۱۳۹۵/۰۲/۲۴, ۰۹:۰۱ ب.ظ
RE: پیلر آنلاین موزیک - توسط shahramm - ۱۳۹۵/۰۲/۲۵, ۰۹:۲۹ ق.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان