How to stream a video file via MCSession?

I'm trying to provide simple *access* to a video file on my Mac to any number of peers using Multipeer Connectivity.


I see that MCSession has some support for generic byte streams, which are different than file transfers. Ideally I need functionality that works like Web Sharing: Given an URL to an .m4v file on Mac or a NAS volume, load and play that URL with AVPlayer on iOS and tvOS.


But as usual, the API documentation for MCSession is dismal. I assume this involves a deep understanding of AVAssetReader, NSOutputStream and NSInputStream. Hopefully it *doesn't* involve decoding/encoding. I can find no sample projects, and google isn't much help because the projects typically don't work. This is an indication that very few people have figured this out.


Any good examples out there I may have missed?

Replies

The gating factor here is the media subsystem. The networking APIs (like Multipeer Connectivity) allow you to move arbitrary chunks of data across the network, but they have no direct integration with the media subsystem. So, there’s two parts to this question:

  • How can you move chunks of data over the network?

  • How can you play media using a custom transport for the data?

You should start by investigating the second point because the answers you get will inform how you structure your networking. And I recommend you post that question over in Media > AVFoundation, where you’re more likely to attract the attention of experts in the media subsystem.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"