Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > Android ช่วยแก้code หน่อยครับ ผมเขียนวิทยุ Radio ออนไลน์ รันแล้วไม่มีเสียงครับ ทำไงดีๆๆๆๆ



 

Android ช่วยแก้code หน่อยครับ ผมเขียนวิทยุ Radio ออนไลน์ รันแล้วไม่มีเสียงครับ ทำไงดีๆๆๆๆ

 



Topic : 084607



โพสกระทู้ ( 16 )
บทความ ( 0 )



สถานะออฟไลน์




http://www.4shared.com/rar/6LlT7ysX/ModelRadio.html?

อันนี้เป็นไฟล์ที่เขียนแล้วครับ แต่ยังไม่มีเสียง



Tag : Android, JAVA







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-09-27 01:29:59 By : YouAreMyFeed View : 2358 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

เอา Code ที่เขียนไว้มาดูดีกว่าครับ โหลดไฟล์มันเสี่ยงครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-09-27 08:53:01 By : mr.win
 


 

No. 2



โพสกระทู้ ( 16 )
บทความ ( 0 )



สถานะออฟไลน์


class : ShowUrl
package com.example.modelradio;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class ShowUrl extends Activity implements View.OnClickListener{
	public static final String TAG="Radio";
	 public static  String station=
			 "org.example.radio.playradio";
	 private static String url;
	Intent int_radio;
	private TextView textUrl;
	private Button btnStart;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.show_radio);
		Log.d(TAG,"Start");
		
		
		textUrl=(TextView) findViewById(R.id.textView2);
		
		//get url from MainRadio
		String test =setUrl(url);
		textUrl.setText(test);
		Log.d("station","staton is : "+test);
		textUrl.setVisibility(View.VISIBLE);
		
		int_radio = new Intent(this,PlayService.class);
		 int_radio.putExtra("url_radio",test);
		
		 btnStart=(Button) findViewById(R.id.btn_option);
		
		 btnStart.setOnClickListener(this);
		
	}
	
	public  static String setUrl(String url) {
		ShowUrl.url = url;
		return url;
	}
	
	public void stopClick(View v){
			stopService(int_radio);
	}
	  private boolean isMyServiceRunning() {
		    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
		    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
		        if ("com.example.modelradio.PlayService".equals(service.service.getClassName())) {
		            return true;
		        }
		    }
		    return false;
		}
	  
	

	public void onClick(View v) {
	
		 if(isMyServiceRunning()){
			  Toast.makeText(getApplicationContext(),"Radio Service is already running...", Toast.LENGTH_LONG).show();
			  btnStart.setText("Stop");
		  }else{
			  startService(int_radio);
		  }
	}

	
}


class PlayService
package com.example.modelradio;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

public class PlayService extends Service {	
	MediaPlayer mediaPlayer;
	Boolean isPlaying = false;
	int noti_id=9988;
	NotificationManager mNM;	
	String url_radio;
	
	private final IBinder mBinder = new LocalBinder();
	@Override
	public IBinder onBind(Intent intent) {
		return mBinder;
	}	
	
	Thread thread = new Thread()
	{
		
		@Override
	    public void run() {
			try {	            
	            	
	            	try{
		            	mediaPlayer.setDataSource(url_radio);
		            	Log.d("url","url radio : "+url_radio);
		                mediaPlayer.prepare();
		                mediaPlayer.start();
	            	}catch(Exception e){
	            		e.printStackTrace();
	            	}finally{	            		
	            		sleep(200);
	            	}
	            	                
	            
	        } catch (InterruptedException e) {
	            e.printStackTrace();
	        }
	    }
	};
	
	@Override
	public void onCreate() {
		super.onCreate();
		
		
		mediaPlayer = new MediaPlayer();

		mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		showNotification();
		
	}
	
	private void showNotification() {		
		Notification notification = new Notification(R.drawable.ic_launcher,null,System.currentTimeMillis());		
		notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;		
		Intent noti = new Intent(this, ShowUrl.class);
		noti.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);		
		PendingIntent contentIntent = PendingIntent.getActivity(this, 0,noti, 0);		
		notification.setLatestEventInfo(this, "myRadio Playing Service","Radio Service is running...", contentIntent);		
		mNM.notify(noti_id, notification);
	}
	
	@Override
    public void onStart(Intent intent, int startId) {        
		super.onStart(intent, startId);
		if(thread.isAlive()){ 
	        
        	return;
        }
		
		Bundle extras = intent.getExtras();
		url_radio = extras.getString("url_radio");        
        Log.d("dbudf","url radio : "+url_radio);
       
        thread.start();
             
    }
 
    @Override
    public void onDestroy() { 
    	
    	if(mediaPlayer.isPlaying()){ 	
    		mediaPlayer.stop();
            mediaPlayer.release();
    	}
    	mNM.cancel(noti_id);
        super.onDestroy();
       
        
       
    }
    
    public class LocalBinder extends Binder {
    	PlayService getService() {
			return PlayService.this;
		}
	}

}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-09-27 10:51:30 By : YouAreMyFeed
 

 

No. 3



โพสกระทู้ ( 16 )
บทความ ( 0 )



สถานะออฟไลน์


logcat_radio
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-09-27 10:53:33 By : YouAreMyFeed
 


 

No. 4

Guest


โค้ทนี้สำหรับเล่นไฟล์ radio แบบ dns ของ radio นะครับ ไม่ใช่ url แบบเว็ปที่เล่นเสียงผ่าน windows media ทั้วไป และถ้าเป็นพวก ไฟล์ .pls นี้ต้องอาศัยโปรแกรมอื่นครับวิธีการเขียนผมก็หาอยู่แต่หาเท่าไรก็ไม่เจอ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-10-06 18:28:30 By : เป็ด
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ผมยังเขียนไม่ถึงครับ ถ้าได้ศึกษาบ้างก็น่าจะช่วยตอบหรือแนะนำได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-10-07 09:33:09 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android ช่วยแก้code หน่อยครับ ผมเขียนวิทยุ Radio ออนไลน์ รันแล้วไม่มีเสียงครับ ทำไงดีๆๆๆๆ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่