RLWithString和NSURL的fileURLWithPa

RLWithString和NSURL的fileURLWithPa

本文介绍了URLWithString和NSURL的fileURLWithPath有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我必须使用 URLWithString 来播放流媒体( HLS )视频和 fileURLWithPath 播放本地视频。

In my code I have to use URLWithString to play streaming(HLS) video and fileURLWithPath to play local video.

这两种方法有什么区别?
我应该如何使用单一方法播放两个视频。

What is the difference between these two methods?How should I use single method to play both videos.

此外,我需要在 HSL时将最后一帧显示为静止图像视频结束。它结束时现在显示空白屏幕。我该怎么做?

Also I need to show last frame as still image when HSL video ends. Its now showing blank screen when it ends. How should i achieve this?

推荐答案

+ URLWithString:产生一个 NSURL 表示给定的字符串。因此字符串可能是 @http://www.google.com,而网址代表 http://www.google.com

+URLWithString: produces an NSURL that represents the string as given. So the string might be @"http://www.google.com" and the URL represents http://www.google.com.

+ fileURLWithPath:获取路径,而不是URL,并生成 NSURL 表示使用 file:// URL的路径。因此,如果您给它 / foo / bar / baz ,则URL将代表 file:/// foo / bar / baz

+fileURLWithPath: takes a path, not a URL, and produces an NSURL that represents the path using a file:// URL. So if you give it /foo/bar/baz the URL would represent file:///foo/bar/baz.

您当然可以手动构建文件URL字符串并将其传递给 + URLWithString:,但 + fileURLWithPath:在您已有路径时更容易使用,因为您不必处理转义字符串并将其强制转换为URL格式。

You can of course construct a file URL string manually and pass it to +URLWithString:, but +fileURLWithPath: is simpler to use when you already have a path, as you don't have to deal with escaping the string and coercing it to a URL format.

这篇关于URLWithString和NSURL的fileURLWithPath有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:27