2009-09-04 9 views
1

再生コントロールとビジュアルを完全に制御して、iPhoneアプリでリモート.mp3を再生するにはどうすればよいですか?私はMPMoviePlayerControllerが.mp3sをストリームできることを知っていますが、それは画面全体を引き継ぎます。フルスクリーンプレーヤーを使用せずにリモートmp3をストリーミングする方法は?例えばshoutcast

あなたは、適切なガイドやクラス参照の指示で私を指すことができたら、それは素晴らしいものです。

答えて

0

AVAudioPlayerを使用して独自のコントロールを作成したい場合があります。

MPMediaPlayerがストリーミングされたmp3を再生できるかどうかわかりませんが、「ipod」プレーヤー(画面を引き継ぐ)ではなく「app」プレーヤーでローカルメディアを再生できます。 MPMediaPlayerは、AVAudioPlayerと似ています。これは、作成できるUIの有無にかかわらず再生できます。再生、一時停止、停止、巻き戻し、転送など。

1

私はAVAudioPlayerがストリーミングmp3をサポートしていないと考えています。私の経験から、私はローカルファイルだけを再生すると言っていることは合理的に確信しています。

AVPlayerを使用してリモートmp3を再生しました。

self.player = [[AVPlayer alloc] initWithURL:fileURL]; 
//inits the AVPlayer object. 
[player addObserver:self forKeyPath:@"status" options:0 context:nil]; 
// You need to watch for for when the player obeject becomes ready to play, using key-value observation 



-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 
{ 
    if(object == player && [keyPath isEqualToString:@"status"]) 
    { 
     playButton.enabled = YES; 
     playButton.titleLabel.text = @"Play"; 
     ..... 
      //do whatever you need to do here to get the object ready to play. 

    } 
} 

シンプルな[プレイヤー再生]がファイルの再生を開始します。

//metadata is available at 
player.currentItem.asset.commonMetadata 
//and time played can be calculated by dividing x by y 
    UInt64 x = self.player.currentTime.value; 
    int32_t y = self.player.currentTime.timescale; 
    int secs = x/y; 
関連する問題