2012-09-22 57 views
0

嗨即時試圖以此來發揮Shoutcast的流中的Android播放Shoutcast的實時流:如何使用鈦工作室

var urlStreaming1 = "http://shoutcasturl:8026"; 

streamer = Ti.Media.createAudioPlayer({ 
     url : urlStreaming[e.source.id], 
     preload : true, 
     allowBackground : true 
    }); 

,但我得到使用最新的鈦Studio版本以及Android的API沒有聲音4.0

Application type: mobile Titanium SDK: Titanium SDK version: 2.1.2 (08/24/12 14:46 ed7f777) 

Platform & version: Android 4.1 google api 

Device: Android emulator 

Host Operating System: OSX 10.8.2 mountain lion 

Titanium Studio: Titanium Studio, build: 2.1.2.201208301612 

回答

0

試試,這段代碼嵌入你的代碼,這是行之有效的。 首先你創建你的AudioPlayer路徑,然後你可以播放和停止。

var sound = Ti.Media.createAudioPlayer({url:'http://202.6.74.107:8060/triplej.mp3'}); 

var stopSound = Titanium.UI.createButton({ 
    title:'Stop Sound', 
    top:160, 
    width:250, 
    height:40 
}); 
stopSound.addEventListener('click', function() 
{ 
    sound.stop(); 
}); 

var startSound = Titanium.UI.createButton({ 
    title:'Play sound', 
    top:110, 
    width:250, 
    height:40 
}); 
startSound.addEventListener('click', function() 
{ 
    Ti.API.info('playing sound with mode ' + modeArray[count].desc + ' count ' + count); 
    sound.play(); 
}); 

乾杯.....!

+0

感謝烏拉圭回合的答案,但我不能使用:(我有Shoutcast的AAC音頻流不.mp3所以我的網址是這樣的:http://184.164.135.242:8026 / – alexistkd

0

試試這個:

爲iOS

使用錄像機,而不是audioPlayer:

var streamer = Ti.Media.createAudioPlayer({ url: 'http://shoutcasturl:8026;', }); 
streamer.start(); 
0

我與鈦把一個應用程序一起,使用以下流的AAC Shoutcast的:

var streamer = Ti.Media.createVideoPlayer({ 
      url : 'http://198.144.148.12:8000/' 
     }); 
     streamer.play(); 

爲Android

audioPlayer或錄像機不支持AAC,在所有所以我制定了以下模塊:

https://marketplace.appcelerator.com/apps/5728