gpt4 book ai didi

操作系统。流媒体网络电台

转载 作者:搜寻专家 更新时间:2023-11-01 05:59:19 30 4
gpt4 key购买 nike

我需要播放不同格式的网络广播。我尝试使用 MPMoviePlayerController 播放广播,但它在 3-4 秒后停止。

var urlAddress = "http://streaming.radionomy.com/Elium-ClubDance";
var url = NSURL( string:urlAddress);
var player = MPMoviePlayerController(contentURL: url)
player.movieSourceType = MPMovieSourceType.Streaming;
player.prepareToPlay();
player.play();

有人知道怎么解决吗?

最佳答案

根据您的问题,我创建了一个新项目并尝试使用以下代码:

import UIKit
import MediaPlayer

class ViewController: UIViewController {

var moviePlayer:MPMoviePlayerController!

override func viewDidLoad() {
super.viewDidLoad()

var url:NSURL = NSURL(string: "http://streaming.radionomy.com/Elium-ClubDance")!

moviePlayer = MPMoviePlayerController(contentURL: url)

moviePlayer.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)

moviePlayer.view.sizeToFit()

moviePlayer.movieSourceType = MPMovieSourceType.Streaming

self.view.addSubview(moviePlayer.view)

moviePlayer.fullscreen = true
moviePlayer.prepareToPlay()
moviePlayer.play()

moviePlayer.controlStyle = MPMovieControlStyle.Embedded

}
}

对我来说工作得很好。

关于操作系统。流媒体网络电台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27037566/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com