【问题标题】:How to make volume slider for AVPlayer in xcode for mac如何在 Mac 的 xcode 中为 AVPlayer 制作音量滑块
【发布时间】:2013-04-16 12:56:42
【问题描述】:

所以我有我的收音机应用程序的简单代码:

 -(IBAction)europaPlus:(id)sender{

        NSLog(@"EuropaPlus work");

        if (clicked ==  0) {

            clicked = 1;

            NSString *urlAddress = @"http://cast.europaplus.ua/europaplus.aac";

            NSURL *urlStream = [NSURL URLWithString:urlAddress];

            radioPlus = [[AVPlayer alloc] initWithURL:urlStream];

            [radioPlus play];}

        else {

            NSLog(@"EuropaPlus not work");

            [radioPlus release];

            clicked = 0;

        }
}

我还使用 AVPLAYER 仅用于 URL 连接,但如何在 MAC OS 中为 AVPlayer 进行音量控制。我知道 IOS 中的 MPMVolumeControl,但我有 mac os 项目。谢谢。

【问题讨论】:

    标签: ios xcode macos volume avplayer


    【解决方案1】:
    player = [[AVAudioPlayer alloc] initWithContentsOfURL:
              [NSURL fileURLWithPath:resourcePath] error:&err];
    player.delegate = self;
    [player play];
    player.volume=.number;
    player.numberOfLoops=-number;
    

    -(IBAction)slidervaluechanged {
    
         player.volume=slider.value; 
    
    }
    

    更多信息请查看链接:

    http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPVolumeView_Class/Reference/Reference.htmlHow do you implement an MPVolumeView?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多