Mac OS AVPlayer Xcode 10.2.1 swift 5.0.1 не будет работать - PullRequest
0 голосов
/ 24 июня 2019

Я пытаюсь создать простой AVBasicPlayBack для Mac OS 10.14.5 Xcode 10.2.1 swift 5.0.1. Я использовал AVPlayer, он выбрасывает некоторые ошибки. Новичок в разработке Mac OS не мог понять, что не так. Я проверил много документации онлайн.

Я добавил NSAppTransportSecurity в файл info.plist, показанный ниже.

файл info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIconFile</key>
    <string></string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSMinimumSystemVersion</key>
    <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2019 Personal. All rights reserved.</string>
    <key>NSMainStoryboardFile</key>
    <string>Main</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>devimages-cdn.apple.com</key>
            <dict/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
</dict>
</plist>

ViewController.swift

import Cocoa
import AVKit

class ViewController: NSViewController {

    @IBOutlet weak var playerView: AVPlayerView!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        guard let url = URL(string: "https://devimages-cdn.apple.com/samplecode/avfoundationMedia/AVFoundationQueuePlayer_HLS2/master.m3u8")
        else {
            return
        }
        // Create a new AVPlayer and associate it with the player view
        //let player = AVPlayer(url: url)
        //playerView.player = player


        let avAsset = AVURLAsset(url: url, options: nil)
        let playerItem = AVPlayerItem(asset: avAsset)
        let videoPlayer = AVPlayer(playerItem: playerItem)
        playerView.player = videoPlayer
        videoPlayer.play()

    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }


}


Я получаю следующие ошибки

2019-06-23 14:03:10.958123-0700 AVBasicPlayback[27278:6522581] [] nw_dictionary_set_value called with null dictionary
2019-06-23 14:03:10.958154-0700 AVBasicPlayback[27278:6522581] [] __nwlog_err_simulate_crash simulate crash failed "nw_dictionary_set_value called with null dictionary"
2019-06-23 14:03:10.958334-0700 AVBasicPlayback[27278:6522581] [] nw_dictionary_set_value called with null dictionary, dumping backtrace:
        [x86_64] libnetcore-1229.250.15
    0   libnetwork.dylib                    0x00007fff747f8c88 __nw_create_backtrace_string + 120
    1   libnetwork.dylib                    0x00007fff7454cb09 nw_dictionary_set_value + 265
    2   libnetwork.dylib                    0x00007fff745e5bce nw_path_evaluator_cancel + 654
    3   MediaToolbox                        0x00007fff4e8ca975 FigMetadataReaderCreateForBoxedMetadata + 10998
    4   MediaToolbox                        0x00007fff4ea170f3 FigBytePumpCreateForHTTPChunk + 73903
    5   MediaToolbox                        0x00007fff4ea06752 FigBytePumpCreateForHTTPChunk + 5902
    6   libdispatch.dylib                   0x000000010034bf1b _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x0000000100354067 _dispatch_lane_serial_drain + 773
    8   libdispatch.dylib                   0x0000000100354f4e _dispatch_lane_invoke + 493
    9   libdispatch.dylib                   0x000000010035e824 _dispatch_root_queue_drain + 334
    10  libdispatch.dylib                   0x000000010035e60b _dispatch_worker_thread + 271
    11  libsystem_pthread.dylib             0x00000001003c5dc3 _pthread_body + 126
    12  libsystem_pthread.dylib             0x00000001003c8e8d _pthread_start + 66
    13  libsystem_pthread.dylib             0x00000001003c4e11 thread_start + 13
2019-06-23 14:03:10.964828-0700 AVBasicPlayback[27278:6522533] startConfigurationWithCompletionHandler: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service named com.apple.rtcreportingd}
2019-06-23 14:03:10.973122-0700 AVBasicPlayback[27278:6522533] startConfigurationWithCompletionHandler: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service named com.apple.rtcreportingd}
2019-06-23 14:03:10.982169-0700 AVBasicPlayback[27278:6522553] Received XPC error Connection invalid for message type 3 kCFNetworkAgentXPCMessageTypePACQuery
2019-06-23 14:03:10.982216-0700 AVBasicPlayback[27278:6522553] PAC result block not invoked
2019-06-23 14:03:10.982273-0700 AVBasicPlayback[27278:6522553] [] nw_proxy_resolver_create_parsed_array PAC evaluation error: kCFErrorDomainCFNetwork: 308
2019-06-23 14:03:10.984342-0700 AVBasicPlayback[27278:6522553] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
2019-06-23 14:03:11.988908-0700 AVBasicPlayback[27278:6522553] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
2019-06-23 14:03:12.990000-0700 AVBasicPlayback[27278:6522553] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
2019-06-23 14:03:13.995302-0700 AVBasicPlayback[27278:6522553] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:11 Err:-1 Errno:1 Operation not permitted
2019-06-23 14:03:13.996203-0700 AVBasicPlayback[27278:6522553] [] nw_resolver_create_dns_service_locked [C1.1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
2019-06-23 14:03:13.997244-0700 AVBasicPlayback[27278:6522553] TIC TCP Conn Failed [1:0x600003716280]: 10:-72000 Err(-65563)
2019-06-23 14:03:13.998574-0700 AVBasicPlayback[27278:6522520] Task <B5B5187F-14BA-498B-91F3-630EE49FBFC0>.<1> HTTP load failed (error code: -1003 [10:-72000])
2019-06-23 14:03:13.998782-0700 AVBasicPlayback[27278:6522520] Task <B5B5187F-14BA-498B-91F3-630EE49FBFC0>.<1> finished with error - code: -1003
2019-06-23 14:03:14.005116-0700 AVBasicPlayback[27278:6522581] Task <B5B5187F-14BA-498B-91F3-630EE49FBFC0>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x600000cdc270 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <B5B5187F-14BA-498B-91F3-630EE49FBFC0>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <B5B5187F-14BA-498B-91F3-630EE49FBFC0>.<1>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://devimages-cdn.apple.com/samplecode/avfoundationMedia/AVFoundationQueuePlayer_HLS2/master.m3u8, NSErrorFailingURLKey=https://devimages-cdn.apple.com/samplecode/avfoundationMedia/AVFoundationQueuePlayer_HLS2/master.m3u8, _kCFStreamErrorDomainKey=10} [-1003]
2019-06-23 14:03:14.007457-0700 AVBasicPlayback[27278:6522520] sendMessageWithDictionary: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service named com.apple.rtcreportingd}

1 Ответ

0 голосов
/ 25 июня 2019

Установите флажок «Исходящие подключения (клиент)» в «Возможности приложения». Это начало отображать видео, но все еще некоторые ошибки. Я обновлю ответ после того, как найду решение для оставшихся ошибок. Ошибки касаются XPC.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...