How do I differentiate between an audio URL and a video URL? - iphone

I have some URLs to play content from, but I have to identify whether the given URL contains video or audio. How can I do this?

The only way to tell what kind of content a URL references is to send a HEAD request and check the Content-Type returned. Or you could just start retrieving the resource and decide what to do with it when you get the headers. That's the approach web browsers take.

Related

Is it possible to provide a URL that returns an m3u8 file to azure media player?

I'm using azure media player to play AES encrypted videos on my website. However, I don't want to use the default HLS streaming uri that comes back.
What I'm doing is loading the m3u8 from the HLS endpoint and adding captions to it directly (Since I can't find a way to add captions through media services itself, if there is one, I'd be all ears). So the url looks something like this: https://website.com/getvideo/100000
This url returns a valid m3u8 file and I can get it playing in other players (unencrypted).
My question is this: Is there a way to get azure media player to recognize this url as a valid return of an m3u8 file? Currently it's not even trying to hit my endpoint and I suspect it's because it's looking for something in the url.
Let me know if you need more information.

Example for google drive simple upload rest API

As per the documentation, if I wish to upload only media without any metadata, the simple upload will do. And the documentation says:
So, as per the documentation, I formed the request as follows and the body of the request is binary data:
But I am not able to figure out where to set the parent directory information for the media being uploaded if the body is comprised of only media.
Do I need to submit two requests, one for metadata and one for media? For that, we are provided with the multipart upload.
Can anyone please help me with a working example of a simple upload?
The form-data section in this Postman docs page might help you with entering the file location.
I found a YouTube video on the subject too.

Show image or video depending on Content-Type in React-Native

I would like to show to the user, in my react-native app, an element reachable on a specific url such as: https://s3-eu-west-1.amazonaws.com/somebucket/somekey
This object has a Content-Type that can be image/jpeg or video/mp4.
If it is an image, it has to be printed in an <Image> component from https://facebook.github.io/react-native/docs/image.html.
If it is a video, it has to be shown in a <Video> component from https://github.com/react-native-community/react-native-video
What is a clean way to show this media without downloading it in a first place (the video can be seen as a stream in <Video>) and without knowing its Content-Type?
Right, the solution that I have found is to do a HEAD request on the media to get the Content-Type and then accessing it from the proper React component. Would you have a better solution to avoid this HEAD request?

When to use "Follow Redirects" & "Redirect Automatically" while recording with jmeter.

I want to know the difference between Follow Redirects and Redirect Automatically while recording with Jmeter.
Also what effect will both these have when used with Retrieve all Embedded Resources from HTML
Redirect automatically, will not consider redirect as a separate request
where as Follow redirects will consider each redirection as a separate request.
This difference can be visualized in the Listener (View Results Tree).
If Retrieve all Embedded Resources from HTML is checked, it will give you Page Load Time, since apart from response time it will keep on calculating the time taken till all the supporting files of html page have been downloaded to Local (CSS, Images, Javascript files.. etc.)
Also if any values needs to be captured from redirect request you need to set configuration a follow redirect otherwise will not be able to capture those data using extractors (set cookie values for example)
Hope this will help.

How do I get the URL fragment (hash) from a Facebook app URL passed to the app's canvas?

I'm coding a "one page" app inside facebook (using the canvas app approach). While the user moves inside the app I'm changing the location like: apps.facebook.com/my-app#current_location and loading stuff via AJAX.
Unfortunetely, when someone loads http://apps.facebook.com/my-app#current_location in their browser, the canvas app doesn't see the url fragment #currrent_page.
How can I get around this limitation?
Although I cannot answer properly your question, (and as I think it's kind of old already) the info below should help other people understand better these # (hash) things. They are called URL Fragments.
http://blog.httpwatch.com/2011/03/01/6-things-you-should-know-about-fragment-urls/
Any URL that contains a # character is a fragment URL. The portion of
the URL to the left of the # identifies a resource that can be
downloaded by a browser and the portion on the right, known as the
fragment identifier, specifies a location within the resource:
Fragments Are not Sent in HTTP Request Messages
If you try using fragment URLs in an HTTP sniffer like HttpWatch,
you’ll never see the fragment IDs in the requested URL or Referer
header. The reason is that the fragment identifier is only used by the
browser – it doesn’t affect which resource is returned from the
server.Here’s a screen shot of HttpWatch showing the traffic generated
by refreshing a fragment URL:
The URL fragment is only read on the client-side (users' browsers), so Facebook won't and can't sent that on the POST request it makes to your server.
What you can do is catch all URLs with the same route, regardless of the server-side language of your choice, encode them somehow, and send them to the client to be read by client-side Javascript which would then be responsible for navigating.
Example: the user loads http://apps.facebook.com/my-app/current_location (notice the / instead of the #). You serve your single page, where you'll have something like (ERB):
<script>MyApp.navigate("<%= request.path %>");</script>
Your navigate function could do the following:
function navigate(path) {
window.location.href = "#" + path;
}
Yeah, the Hash urls are nice to use for navigation within your site, however, not so good when sharing the url. The solution is to create canonical URLs for each of your objects.
So, when someone can access specific information like http://yoursite.com/#artists/styx, you also have a way for your server to serve content from http://yoursite.com/artists/styx. This way someone can share http://apps.facebook.com/yoursiteapp/artists/styx and then get to the correct content within your site.