2012-12-18 11 views
8

UIWebViewでウェブサイト(HTML5ビデオタグ付き)から.mp4ビデオを再生しようとしました。 iPhone/iPadのデバイスとシミュレータには、再生ボタンを押した黒いフレームのみが表示されます。 Safari Mac版でこのウェブサイトを呼び出せば、それを再生することができます。 どうしますか?UIWebviewはmp4を再生していませんビデオ

ローカルファイルではありません。 htmlは次のようになります。

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <meta charset="utf-8" /> 
     <link rel="stylesheet" type="text/css" href="../css/shared-culture.css" /> 
    </head> 
    <body> 
     <section class="base"> 
      <hgroup> 
       <h1>creative commons</h1> 
       <h2>a shared culture</h2> 
      </hgroup> 

       <p>To celebrate our 2008 fundraising campaign, Creative Commons has 
        released “A Shared Culture,” a short video by renowned filmmaker <a 
         href="http://en.wikipedia.org/wiki/Jesse_Dylan">Jesse Dylan</a>. Known for 
        helming a variety of films, music videos, and the Emmy Award-winning <a 
         href="http://my.barackobama.com/page/invite/yeswecanvideo">“Yes We Can”</a> 
        Barack Obama campaign video collaboration with rapper will.i.am, Dylan created 
        “A Shared Culture” to help spread the word about the Creative Commons mission. </p> 
       <!-- height="240" width="360" --> 
       <video id="video1" controls="controls"> 
        <source src="../video/shared-culture.mp4" type="video/mp4"/> 
        <source src="../video/shared-culture.webm" type="video/webm"/> 
        <div class="errmsg"> 
         <p>Your Reading System does not support (this) video.</p> 
         <pre><code> 
&lt;video id="video1" controls="controls"&gt;      
    &lt;source src="../video/shared-culture.mp4" type="video/mp4"/&gt; 
    &lt;source src="../video/shared-culture.webm" type="video/webm"/&gt;  
&lt;/video&gt; 
         </code></pre> 
        </div> 
       </video> 
       <p>In the video, some of the leading thinkers behind Creative Commons 
        describe how the organization is helping “save the world from failed sharing” 
        through free tools that enable creators to easily make their work available to 
        the public for legal sharing and remix. Dylan puts the Creative Commons system 
        into action by punctuating the interview footage with dozens of photos that have 
        been offered to the public for use under CC licenses. Similarly, he used two 
        CC-licensed instrumental pieces by Nine Inch Nails as the video’s soundtrack 
        music. These tracks, “17 Ghosts II” and “21 Ghosts III,” come from the Nine Inch 
        Nails album Ghosts I-IV, which was released earlier this year under a Creative 
        Commons BY-NC-SA license. (See <a 
         href="http://creativecommons.org/videos/a-shared-culture">attribution</a>.) 
       </p> 

     </section> 

    </body> 
</html> 
+0

は、あなたの 'HTML'コードを投稿できますか? – arthankamal

+0

あなたはそのウェブサイトでビデオを再生したい場合は、[VideoPlayerKit](https://github.com/ign/VideoPlayerKit)をチェックしてください。 –

+1

ちょうどhttp://my.barackobama.comのページソースを見ました。 。 。/ video/shared-culture.mp4'とし、 'type =" application/x-shockwave-flash "という属性を持つmovie埋め込みタグを宣言しています。 Apple HLSの場合は、MPEG2.TSコンテナにH.264/AVCが必要です。 HLSドキュメントはこちら:https://developer.apple.com/resources/http-streaming/ –

答えて

2

コーデックの問題のような音がします。コンピュータのVLCでファイルを開くと、ファイルが使用するコーデックを確認できます。ウィンドウ - >メディア情報 - >コーデックの詳細に移動します。あなたがサポートされているビデオおよびオーディオコーデックを見つけるAppleのドキュメントへの答えhereリンク:

https://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html

https://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html

9

それはiPhoneフレンドリーなフォーマットでないかもしれません。その後、

のiMovieにドラッグmp4ファイルをと共有をクリックしてください - >ムービー書き出しとiPhone互換形式のいずれかを選択します。

+0

私はAdobe Media Encoderでビデオを再エンコードしなければなりませんでした(iOS 8.3)。私のビデオはかなり短かった(3秒)。 – Chris

1

あなたが使用している相対../パスに問題がある可能性があります。 http://で始まるフル絶対パスを使用してみてください。

4

ビデオがUIWebViewで再生できない方法の1つは、ビデオファイルをホストするWebサーバーがバイト範囲をサポートしていない場合です。 UIWebViewは一度に.mp4ファイル全体をダウンロードしません。代わりに、ファイルの一部を要求することによってビデオをストリームします。最近のほとんどのサーバーではバイト範囲がサポートされていますが、そうでない場合、または何らかの理由でオフにした場合、iOSデバイスにビデオを配信することはできません。

0

は、私もこの問題を持って、私は2 .mp4を持っているが、1つを使用することができますし、1ではない、私はiPad用.mp4にタイプのファイル.mp4をフォーマットしようとそれは仕事だ、私はあなたが試みるべきだと思います。

-1

iPhoneの番組でmp4ビデオを再生することはあまり難しくありません。ちょうど我々は1つの余分なドラッグアンドドロップを行う必要があります。

新しい単一のプロジェクトをご覧ください。その後、ViewController.mファイルにちょうど次にHTMLファイルに

<!DOCTYPE html> 
<html> 
<head></head> 

<body> 
    <center> <video width="250" height="304" controls preload> 
     <source src="video1.mp4" type="video/mp4"> 
      </video> </center> 

    <p>Thanks to Md Kamrul Hasan [email protected]</p> 

    </body> 
</html> 
をtestingHTML.html

という名前のHTMLファイルを作成し、次のコードをコピー&ペーストコピーして、このコード

#import "ViewController.h" 

    @interface ViewController() 

    @end 

    @implementation ViewController 
    @synthesize webView; 
- (void)viewDidLoad { 
[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 

CGRect screenRect = [[UIScreen mainScreen] bounds]; 

CGFloat screenWidth = screenRect.size.width; 
CGFloat screenHeight = screenRect.size.height; 

webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0,screenWidth,screenHeight)]; 


NSURL *url = [[NSBundle mainBundle] URLForResource:@"testingHTML" withExtension:@"html"]; 
NSLog(@"%@",url); 
[self.webView loadRequest:[NSURLRequest requestWithURL:url]]; 



// NSURL *nsurl=[NSURL URLWithString:url]; 
//NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl]; 
// [webView loadRequest:nsrequest]; 
[self.view addSubview:webView]; 





} 

- (void)didReceiveMemoryWarning { 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

@end 

を貼り付け

MP4タイプのビデオを2つの場所にドラッグアンドドロップ:

最初に:HDDからプロジェクトタブにビデオをドラッグします[Xcodeの左タブ] 2番目: Xcodeの左のタブから再度同じビデオファイルをプロジェクトにドラッグ--->ビルド段階--->バンドルリソースのコピー

通常、コピーバンドルにはプロジェクトファイルがありますが、ビデオファイルが含まれていないことがあります。

今プロジェクトを実行して、ビデオを楽しんで......!

幸運

+0

https://drive.google.com/file/d/0B-YyYsAL0QKLRWJRdHVxbXhwNUU/view?usp=sharing –

+0

私は2つのウェブビューで2つのビデオを再生しようとしますが、シングルビデオしか再生しません。 –

関連する問題