From Remote URL
VideoEditor SDK supports loading video files from a remote URL, this can be a resource hosted by a video hosting provider such as Vimeo or Wistia or your own servers.
Download the video file#
Although you can pass a URL directly to the editor, we strongly recommend that you manage downloading the remote resource yourself. This allows you more control over where and how the download task is being executed and avoid potential problems around UI locking.
Hence we create a download task and move the downloaded file to a temporary directory to obtain a local URL. We save this URL in the instance variable
localURL to be able to reference it outside of the current task.
In between, we are performing a bit of housekeeping ensuring that no files exists at the temporary location.
Initialize the editor#
When the download is finished, we hand off to the main queue to initialize a
Video from the
localURL and pass it as
videoAsset to the
VideoEditViewController to instantiate the video editor.
Setting the current class the delegate of the
VideoEditViewController allows us to implement export, cancellation and error handling there.
Handling user interaction#
While the download task is executing we disable user interaction. In production you might might want to indicate download progress here.
When the download finished, we can reenable user interaction and dismiss the progress indicator.