MediaPlayerLauncher with HTTPS - windows-phone-7

I would like to open an audio file from an HTTPS resource.
First, I tried using MediaPlayerLauncher like so:
MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher {
Media = filename,
Controls = MediaPlaybackControls.Pause,
Orientation = MediaPlayerOrientation.Portrait,
Location = MediaLocationType.None
};
mediaPlayerLauncher.Show();
filename in this case is a URL beginning with https://.
Using Fiddler to monitor traffic, I have noticed that https:// in filename is getting changed to http://.
Next I tried opening the same URL using WebBrowserTask:
WebBrowserTask webBrowser = new WebBrowserTask {
Uri = filename
};
webBrowser.Show();
Checking Fiddler out again, I noticed that two requests are being sent. First is a request to filename by the browser. This results in the "Tap to open file" message to appear in the browser. Tapping it opens the phone's media player (MediaPlayerLauncher?), which sends another request -- in this case, the https:// changed to http:// again (which is similar result to first attempt).
The server I am getting the file from only supports HTTPS, hence the problems arising when the media player requests the file as HTTP.
Is there anyway to stream a file from an HTTPS resource? Does Windows Phone's media player even support it?

Pointing location on the internet for the MediaLuncher is a bad idea. It will freez UI thread and your app won't be responsive. Try first download the audio as a stream and then play it. Use WebClient to open a stream. HTTPS can be open in WP7, so that shouldn't be a problem.

Related

DIAL with Cobalt

Cobalt can default load the URL. We are investigating how to add the DIAL paring code to the URL. Maybe it needs a changeURL API for avoiding re-launching YouTube.
// Restrict navigation to a couple of whitelisted URLs by default.
const char kYouTubeTvLocationPolicy[] =
"h5vcc-location-src "
"https://www.youtube.com/tv "
"https://web-release-qa.youtube.com/tv "
[scenario]
launch YTTV with your remote controller
open YouTube app on your phone
try to pairing to TV
Cobalt currently doesn't implement DIAL smooth-pairing once launched, but it does support being launched with alternate query parameters via the --url= command-line parameter.
For example:
https://www.youtube.com/tv?...anything...
Will pass the navigation whitelist.
Full implementation of smooth-pairing support is planned for Q1 2017.

How to convert IHTMLImgElement to image

I am automating Internet Explorer using SHDocVW.dll and MSHTML with C#, and I wish to save an image from the page to the disk (JPEG format).
I can't use the WebClient class to download the image; if I do it, I end up downloading the site's login page. I can't print the screen either, because the browser has to remain invisible during this process, running in the background.
I have tried to do the following:
IHTMLImgElement imgElement = ...;
IHTMLControlRange imgRange = ...;
imgRange.add(imgElement as IHTMLControlElement);
imgRange.execCommand( "copy", false, null );
This does nothing. I am not able to extract anything from the clipboard. Every solution I found didn't work for me.
Your webclient approach is probably missing cookies... see How do I log into a site with WebClient? for an example that handles cookies.
your code looks fine except the user has to change the security setting to enable clipboard access. If the image is cached on disk you can dig the WinInet cache after parsing the page for the image location.

Creating a player app on chromecast

I've had lots of progress on this and wanted to implement the "invisible player" on the chromecast receiver as explained here:Deezer invisible player
I have my demo app running, and am able to pass from the sender to the receiver my access token and my token expires.
Instanciating the DZ player like so:
DZ.init({
appId : deezer_app_id,
channelUrl : deezer_channel_url,
player : {
onload : onPlayerLoaded,
token : {
accessToken:event.message.accessToken,
expire:event.message.expire
}
}
});
the onPlayerLoaded function just logs a message for the time being.
I am currently getting:
Unsafe JavaScript attempt to access frame with URL http://mydomain/chrome/myreceiver.html from frame with URL http://www.deezer.com/es/plugins/player.php?channel=http://Mydomain/chrome/channel.php&app_id=IDVALUE&emptyPlayer=true. Domains, protocols and ports must match.
external-v00202097.js:40
FB.getLoginStatus() called before calling FB.init(). vb.js:56
Flash is not installed or is too old vb.js:56
Unsafe JavaScript attempt to access frame with URL http://mydomain/chrome/myreceiver.html from frame with URL http://static.ak.facebook.com/connect/xd_arbiter.php?version=27#channel=f3a…Ffb_xd_fragment%23xd_sig%3Df2d6a19d8%26&origin=http%3A%2F%2Fwww.deezer.com. The frame requesting access set 'document.domain' to 'facebook.com', but the frame being accessed did not. Both must set 'document.domain' to the same value to allow access.
xd_arbiter.php:18
Unsafe JavaScript attempt to access frame with URL http://Mydomain/chrome/myreceiver.html from frame with URL https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=27#channel=…Ffb_xd_fragment%23xd_sig%3Df2d6a19d8%26&origin=http%3A%2F%2Fwww.deezer.com. The frame requesting access has a protocol of 'https', the frame being accessed has a protocol of 'http'. Protocols must match.
now the first one does not make sense, as I have my channelURL set to the same domain, looking with the inspector I can guarantee both on the channelURl and on the chrome cast receiver that we have the same document.domain .
the second error seems to be from deezer loading something in flash (weird as the example does not state anything in flash).
the third error would be deezer calling FB for some reason.
I know the youtube api through Iframe has been made to work with chromecast, so I think this is possible, however the flash problem and cross domain seems to be an issue.
Any advice?
About the domain, sometimes you get errors when the domain you specified for your app on http://developers.deezer.com contains http:// as it shouldn't.
About Flash, the Deezer player is based on Flash for encryption so you need to install it to get it to work.
Facebook is included in the Deezer player (for sharing, login purposes) and you get warnings when your page is loaded within iframes. You can ignore these warnings.
I am not familiar with Deezer so won't be able to comment on Deezer related issues but the "Unsdafe ..." message can also be caused by trying to use file://*; this is an additional security measure in Chrome. In addition, what are the sanbox properties of the iframe? Does it include "allow-same-origin" ?

Streaming MP3 audio to HTML5 audio tag from servlet

I'm having some cross-browser compatibility joys. I have a Ruby WEBrick server with a couple of servlets, one of which is used to stream media (Ogg and MP3). The servlet gets a couple of query parameters (a base64 urlsafe string key, a small string user, and a small number, sid). When I put the URL verbatim into Chrome, I get the QuickTime extension, and it works. When I post the same into FireFox, I get the expected unsupported codec. When I put it in Safari, it works. However, the URL is not being accessed directly. I have a jQuery Mobile app that uses the Javascript Buzz library, and uses these servlet streaming URLs as sources. The code works in Safari, allowing me to play the sounds. On FireFox, instead of falling back onto Ogg, it gives unsupported errors, and on Chrome, it does nothing. Here's the code that serves the MP3:
res.status = 200
str = File.new("Music/#{req.query['sid']}.mp3", 'r:BINARY:BINARY').read
res.body = str
res['content-type'] = 'audio/mpeg'
Can anyone tell me how to get audio streaming to all browsers through a Ruby servlet?
Note: This is not a duplicate. I've been thorough a lot of SO answers, but none work because they are designed for static files, not servlets.

How can I start QuickTime and have it start playing a url?

I'm using MonoMac, but I understand cocoa and objc well enough that if you can answer me in those languages, please do.
I have a url from my web server which returns an mp4. I'd like my MonoMac application to launch QuickTime and start playing that url.
I tried these methods:
Process.Start("/Applications/QuickTime Player.app/Contents/MacOS/QuickTime Player", url);
but when the url is something like http://webhost/1/blah.mp4, quicktime says "The document blah.mp4 could not be opened. The file doesn't exist. I know the file exists and everything is correct. If I use this method:
var cfurl = MonoMac.CoreFoundataion.CFUrl.FromUrlString(url, null);
LSOpenCFURLRef(cfurl.Handle, (IntPtr)null);
The stream is opened in Safari and the QuickTime plugin starts playing it.
I've also tried NSWorkspace OpenUrls and OpenFile
NSWorkspace.SharedWorkspace.OpenUrls(new[]{NSUrl.FromString(url)},
#"com.apple.quicktimeplayer",
NSWorkspaceLaunchOptions.Async,
new NSAppleEventDescriptor(),
new[]{""});
but this launches in safari
NSWorkspace.SharedWorkspace.OpenFile(url, "QuickTimePlayer");
but this does nothing.
So I try NSTask
MonoMac.Foundation.NSTask.LaunchFromPath("/Applications/QuickTime Player.app/Contents/MacOS/QuickTime Player",
new string[] {url});
But this gives the same "... could not be found..." as my very first attempt above.
Finally, if I start QuickTime Player and use open URL and paste the url into the textbox and click Open, the stream plays without error.
How can my cocoa app send a URL to QuickTime Player?
Considering the URL is a remote URL, you can use Scripting Bridge in Cocoa applications to ask QuickTime Player to open a remote URL:
id qtApp = [SBApplication applicationWithBundleIdentifier:#"com.apple.QuickTimePlayerX"];
[qtApp activate];
if ([qtApp isRunning]) {
// note that the parameter to openURL: must be the string representation of a URL
[qtApp openURL:#"http://movies.apple.com/media/us/ipad/2011/tours/apple-ipad2-feature-us-20110302_r848-9cie.mov?width=848&height=480"];
}
You’ll need to link the Scripting Bridge framework to your application.

Resources