开发者

Phonegap-0.94, Apple iPhone OS 4.2.1 : Youtube links not launching Youtube app

开发者 https://www.devze.com 2023-02-25 09:35 出处:网络
I created a basic project using phonegap. and added this bit of html code to my index.hmtl Clicking on the youtube link launches Youtube mobile site in Phonegap (once it\'s launched, there is no way

I created a basic project using phonegap. and added this bit of html code to my index.hmtl Clicking on the youtube link launches Youtube mobile site in Phonegap (once it's launched, there is no way to go back to my phonegap view)

How do I enable HREF links to open native youtube app on iPhone/iPad? The href links are compliant with Apple specs for Youtube Links as in https://developer.apple.com/library/safari/#featuredarticles/iPhoneURLScheme_Reference/Articles/YouTubeLinks.html

My Index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ 
TR/html4/strict.dtd"> 
<html> 
  <head> 
        <!-- Change this if you want to allow scaling --> 
    <meta name="viewport" content="width=default-width; user- 
scalable=no" /> 
    <meta http-equiv="Content-type" content="text/html; 
charset=utf-8"> 
    <title>MyTube</title> 
        <!-- iPad/iPhone specific css below, add after your main css > 
        <link rel="stylesheet" media="only screen and (max-device-width: 
1024px)" href="ipad.css" type="text/css" /> 
        <link rel="stylesheet" media="only screen and (max-device-width: 
480px)" href="iphone.css" type="text/css" /> 
        --> 
        <!-- If you application is targeting iOS BEFORE 4.0 you MUST put 
json2.js from http://www.JSON.org/json2.js into your www directory and 
include it here --> 
        <script type="text/javascript" charset="utf-8" src="phonegap. 
0.9.4.min.js"></script> 
    <script type="text/javascript" charset="utf-8"> 
        // If you want to prevent dragging, uncomment this section 
        /* 
        function preventBehavior(e) 
        { 
      e.preventDefault(); 
    }; 
        document.addEventListener("touchmove", preventBehavior, false); 
        */ 
        function onBodyLoad() 
        { 
                document.addEventListener("deviceready",onDeviceReady,false); 
        } 
        /* When this function is called, PhoneGap has been initialized and is 
ready to roll */ 
        function onDeviceReady() 
        { 
                // do your thing! 
        } 
    </script> 
  </head> 
  <body onload="onBodyLoad()"> 
        <h1> My开发者_开发技巧 You tube Links </h1> 
        <a href="http://www.youtube.com/v/NkTrG-gpIzE"> SOURCE-CODE 
Trailer </a> 
  </body> 
</html> 


I tried and got the same result. Which is weird, because I also assumed links to YT would trigger the native YouTube app. The one thing I found is that an embed will do what you're after, but haven't come across any other way.

<object width="300" height="199">
    <param name="movie" value="http://www.youtube.com/v/NkTrG-gpIzE?fs=1&amp;hl=en_US&amp;rel=0"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/NkTrG-gpIzE?fs=1&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="199"></embed>
</object>

My only other suggestion was to have you post on the PhoneGap Google Group, but I see that you've just done that a few minutes ago. If I find anything else I'll try to share it, but the embed approach has been the only one that's worked so far.

0

精彩评论

暂无评论...
验证码 换一张
取 消