18

Làm cách nào để phát video trực tiếp lên Android (2.1 trở lên), tôi có hai liên kết: m3u8f4m (Như tôi biết, f4m không được hỗ trợ).phát video trực tiếp lên Android

Từ những gì tôi nhìn thấy trên stackoverflow, có một cách để dòng m3u8 với vitamio (nhưng liên kết không hoạt động).

Có cách nào khác để phát video m3u8 không? Có thể có định dạng khác mà tôi có thể sử dụng?

Cảm ơn.

Trả lời

32

Vì không ai trả lời câu hỏi của tôi, tôi sẽ tự làm.

Nếu bạn muốn thực hiện HLT (luồng trực tiếp HTTP) trên Android 2.1 trở lên, bạn có thể sử dụng thư viện vitamio.

Trang web tại: (http://www.vitamio.org/).

Đây là mã ví dụ: Cách bố trí chính:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout android:id="@+id/LinearLayout01" 
      android:layout_height="fill_parent"   xmlns:android="http://schemas.android.com/apk/res/android" 
      android:paddingLeft="2px" android:paddingRight="2px" 
      android:paddingTop="2px" android:paddingBottom="2px" 
      android:layout_width="fill_parent" android:orientation="vertical"> 

      <io.vov.vitamio.widget.VideoView 
       android:layout_height="fill_parent" 
       android:layout_width="fill_parent" android:id="@+id/VideoView">    
      </io.vov.vitamio.widget.VideoView> 
</LinearLayout> 

Class:

import io.vov.vitamio.widget.MediaController; 
import io.vov.vitamio.widget.VideoView; 
import android.app.Activity; 
import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 



public class LiveStrimingTestActivity extends Activity{ 

    VideoView videoView; 

    private void test_2(){ 
     String httpLiveUrl = "http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8"; 
     videoView = (VideoView) findViewById(R.id.VideoView); 
     videoView.setVideoURI(Uri.parse(httpLiveUrl)); 
     MediaController mediaController = new MediaController(this); 
     videoView.setMediaController(mediaController); 
     videoView.requestFocus(); 
     videoView.start(); 
    } 


    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     test_2();    
    }  
} 
+1

Chúng ta có thể sử dụng vitamio cho RTMP không ?? –

+0

Làm cho ngày của tôi! Tks –

+1

Cách thêm thư viện vitamio ?? plz –

3

Tôi đã thử nghiệm cùng một luồng trên các thiết bị với hệ điều hành 2.2, 2.3.4 và 4.0.4 . Luồng này phát rất tốt với VideoView thông thường trên các thiết bị tôi có. Tôi không sử dụng MediaController với các luồng trực tiếp. Phần còn lại của mã là đơn giản.

initializeVideoView(); 
mVideoView.setVideoURI(Uri.parse("http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8")); 
mVideoView.setMediaController(null); 
mVideoView.start(); 
+0

làm thế nào tôi có thể nhận được liên kết m3u8 từ liên kết nhúng dailymotion như thế này http://www.dailymotion.com/embed/video/x2qo9ad –

0

KickFlip là thư viện mã nguồn mở và miễn phí để phát trực tuyến video và dễ cài đặt.

Kickflip.initWithApiKey(API_KEY, API_SECRET); 
Kickflip.startBroadcastActivity(this, mBroadcastListener); 

dùng thử.

-1

Để thêm vitamio vào dự án của bạn, chỉ cần thêm phụ thuộc này. biên dịch 'me.neavo: vitamio: 4.2.2' và sau đó là @butter đã bảo bạn làm. Happy Coding.good luck

Các vấn đề liên quan