作者 主題: 網頁使用jw player播放flv檔,ipad無法觀看的問題  (閱讀 24402 次)

0 會員 與 1 訪客 正在閱讀本文。

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
這幾天要寫個在網頁播放flv檔的程式,找了一下,發現jw player好像滿方便的

照著網路上找的範例修修改改,總算可以在網頁播放flv檔

接著想到,jw player 5.8 的說明好像有說到在iphone/ipad也可以播放

心動不如馬上行動的我打開ipad輸入網址試試,結果,什麼東西也沒跑出來,怪了,不知道是不是程式碼的問題??

附上網址跟程式碼,請有研究的大大指導一下
http://www.shop101.asia/jw/jwshow.php

代碼: [選擇]
<body>
<p id='preview'></p>
<script type='text/javascript' src='/jw/jwplayer/swfobject.js'></script>
<script type='text/javascript'>
var s1 = new SWFObject('/jw/jwplayer/player.swf','player','400','300','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=/jw/video/lathe.flv');
s1.write('preview');
</script>

</body>

micmic3

  • 俺是博士!
  • *****
  • 文章數: 1693
    • 檢視個人資料
IOS 不支援 flash
--
ipod iphone ipad 都不行

twu2

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 5417
  • 性別: 男
    • 檢視個人資料
    • http://blog.teatime.com.tw/1
請用 html5 方式.
如下:
代碼: [選擇]
<script type="text/javascript" src="jwplayer.js"></script>
<div id="container">Loading the player ...</div>
<script type="text/javascript">
    jwplayer("container").setup({
        'height': '260',
        'width': '320',
        'file': "DSCN0207.mp4",
      'title': 'test',
      'autostart': 'true',
      'bufferlength': '10',
      'controlbar': 'bottom',
      'display.showmute': 'true',
      'stretching': 'uniform',
      'wmode': 'transparent',
     'modes': [
         { 'type': 'flash', 'src': 'player.swf' },
         { 'type': 'html5' },
         { 'type': 'download' }
        ]
    });
</script>

有支援 flash 就用 flash, 沒有就用 html5.
modes 的順序可以隨你改... 不過建議先 flash 後 html5, 再來是 download...
因為 firefox 對 html5 的 mp4 不支援, 把 html5 放前面反而會造成 firefox 不能看.

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
感恩!!小弟我再研究看看

micmic3

  • 俺是博士!
  • *****
  • 文章數: 1693
    • 檢視個人資料
請用 html5 方式.
如下:
代碼: [選擇]
<script type="text/javascript" src="jwplayer.js"></script>
<div id="container">Loading the player ...</div>
<script type="text/javascript">
    jwplayer("container").setup({
        'height': '260',
        'width': '320',
        'file': "DSCN0207.mp4",
      'title': 'test',
      'autostart': 'true',
      'bufferlength': '10',
      'controlbar': 'bottom',
      'display.showmute': 'true',
      'stretching': 'uniform',
      'wmode': 'transparent',
     'modes': [
         { 'type': 'flash', 'src': 'player.swf' },
         { 'type': 'html5' },
         { 'type': 'download' }
        ]
    });
</script>

有支援 flash 就用 flash, 沒有就用 html5.
modes 的順序可以隨你改... 不過建議先 flash 後 html5, 再來是 download...
因為 firefox 對 html5 的 mp4 不支援, 把 html5 放前面反而會造成 firefox 不能看.

=.=b 讚!

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
代碼: [選擇]
<script type="text/javascript" src="jwplayer.js"></script>
<div id="container">Loading the player ...</div>
<script type="text/javascript">
    jwplayer("container").setup({
        'height': '260',
        'width': '320',
        'file': "DSCN0207.mp4",
      'title': 'test',
      'autostart': 'true',
      'bufferlength': '10',
      'controlbar': 'bottom',
      'display.showmute': 'true',
      'stretching': 'uniform',
      'wmode': 'transparent',
     'modes': [
         { 'type': 'flash', 'src': 'player.swf' },
         { 'type': 'html5' },
         { 'type': 'download' }
        ]
    });
</script>

感謝twu2的指導,前陣子被抓去做Discuz的東西=.=
這兩天回來試jwplayer,照著程式碼改,在ipad上可以播了,但是又出現了別的問題
ipad會把整個影片檔下載完才播,請問這是正常的嗎?

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
我將modes改為只有html5
代碼: [選擇]
'modes': [
         { 'type': 'html5' }
        ]

結果只有Loading the player ...
在IE、Google Chrome都是
modes用flash跟download都可以,只有html5不行
這是為什麼呢?

twu2

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 5417
  • 性別: 男
    • 檢視個人資料
    • http://blog.teatime.com.tw/1
你用 ipad 可以看, 就表示是用 html5.
至於為什麼只用 html5 反而不行? 要我猜的話, 我會猜是你改錯了.....

用 html5 的時候, 自己在 chrome 看那個元件的 code, 就會發現被改成用 <video> tag.

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
可是ipad是整個下載完,然後要另外用軟體來播放,比較像是download下來
我剛剛突然想說,那用jwplayer裡面附的mp4來試試

代碼: [選擇]
<script src="jwplayer.js" type="text/javascript"></script>
<div id="myplayer"></div>
<script type="text/javascript">
jwplayer("myplayer").setup({
    height: 360,
    levels: [
        {file: 'video.mp4', type: 'video/mp4' },
    ],
    modes: [
        { type: 'html5' }
    ],
    width: 640
});
</script>

神奇的是ipad可以看了,可是改成flv檔又不行了

代碼: [選擇]
<script src="jwplayer.js" type="text/javascript"></script>
<div id="myplayer"></div>
<script type="text/javascript">
jwplayer("myplayer").setup({
    height: 360,
    levels: [
        {file: 'video.flv' },
    ],
    modes: [
        { type: 'html5' }
    ],
    width: 640
});
</script>

可是html5不是也能播flv嗎
還是因為type的問題呢? 網路上只找到video/mp4、video/webm、video/ogg,似乎沒有flv??
請了解的人解惑一下,謝謝
« 上次編輯: 2012-01-04 15:19 由 fighting neeb »

twu2

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 5417
  • 性別: 男
    • 檢視個人資料
    • http://blog.teatime.com.tw/1
你應該自己先用 html5 的 video tag 測試一下看看, 如果可以用, 再來看 jwplayer 幫你轉出來的 code 對不對. (用 firefox 或 google chrome 應該都可以看到轉出來的 code)
jwplayer 在使用 html5 時, 只是透過 DOM 把那個 <div> 改成 html5 的 <video> 來用.

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
我用了一個簡單的video tag測試
代碼: [選擇]
先用了
<video id="video" src="lathe.flv"
width=960 height=540 controls="controls">
</video>
畫面是黑的,無法播放

加了type試試
<video id="video" src="lathe.flv" type="video/flv"
width=960 height=540 controls="controls">
</video>
畫面還是黑的,無法播放

把影片檔改為mp4
<video id="video" src="video.mp4"
width=960 height=540 controls="controls">
</video>
可以播放video.mp4

所以,flv無法使用html5播放,只能以flash播放嗎?(疑問)

twu2

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 5417
  • 性別: 男
    • 檢視個人資料
    • http://blog.teatime.com.tw/1
http://en.wikipedia.org/wiki/HTML5_video
為什麼你會認為 html5 支援 flv?
我看到的規格只有 ogg/h264 (mp4)/webm 三個.

fighting neeb

  • 可愛的小學生
  • *
  • 文章數: 11
    • 檢視個人資料
因為網路上有些文章說可以用html5播flv檔,後來研究一下似乎還是使用flash來播
http://gettingsoftware.posterous.com/html5flash-using-html5-video-and-audio-right
想知道到底有沒有辦法使用html5來播放flv檔,所以才想試著做做看
現在看來flv檔還是不能用html5來播,還是謝謝 twu2 的指導