如何从URL流式传输实时视频?

时间:2019-03-12 09:31:19

标签: android android-fragments video-streaming live-streaming

我想将此link嵌入我的android应用程序中。我尝试这样做,但是视频无法加载。我还收到错误java.io.FileNotFoundException:没有内容提供程序:

    Sub creatpdf()
    Dim lLastRow As Long
    Dim sPath As String, sNewFolder As String
    Dim x As String
    Dim wsA As Worksheet
    Dim wbA As Workbook
    Dim strName As String
    Dim strPath As String
    Dim strFile As String
    Dim strPathFile As String
    Dim myFile As Variant
    On Error GoTo errHandler
    Set wbA = ActiveWorkbook
    Set wsA = ActiveSheet
   With Worksheets("Output_" & Date)
    fName5 = .Range("D3").Value
    fName3 = "PO_"
    fName1 = "000"
    fName2 = .Range("B3").Value
    fName4 = "_" 
    End With        
   BrowseForFolder = CurDir()
   sPath = BrowseForFolder & "\" & fName3 & fName5 & "\"

lLastRow=Workbooks(sFilename).Sheets(1).Range("A:A").SpecialCells(xlCellTypeLastCell).Row


Workbooks(sFilename).Sheets(1).Activate
 For i = 2 To lLastRow
If Workbooks(sFilename).Sheets(1).Cells(i, 5).Value >= 1 Then

    sNewFolder = "000" & ActiveSheet.Range("B" & i).Value & "_" & ActiveSheet.Range("D" & i).Value & "_" & ActiveSheet.Range("I" & i).Value & "_" & Format$(Date, "yyyymmdd") & "\" & BOM

    If Dir(sPath & "\" & sNewFolder, vbDirectory) = "" Then


With ActiveSheet.PageSetup

End With


  strPath = wbA.Path
  If strPath = "" Then
  strPath = Application.DefaultFilePath
  End If
  strPath =sPath & "\" & sNewFolder

  strName = Folder_BOM & "\" & fName5 & fName6

  'create default name for savng file

  strFile = strName & ".pdf"
  strPathFile = strFile

'export to PDF in current folder
    wsA.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=strPathFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False

    MsgBox "PDF file has been created: " _
      & vbCrLf _
      & strPathFile

exitHandler:
    Exit Sub
errHandler:
    MsgBox "Could not create PDF file"
    Resume exitHandler



  End If

     End If
  sNewFolder = vbNullString
   Next


 End Sub

1 个答案:

答案 0 :(得分:0)

在这个问题上,当涉及到较新的URL时,“本机视频视图”非常有限,并且(*我认为)不再更新。尝试改用Vitamio视频播放器。这对于多种流功能非常有用。

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

此外,请勿立即调用start()方法。仅在您的OnPreparedListener()回调中调用它。

Vitamio.isInitialized(getApplicationContext());

mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mediaPlayer) {
        // optional need Vitamio 4.0
        mediaPlayer.setPlaybackSpeed(1.0f);
    }
});

或者您也可以使用KickFlip。设置非常简单,

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

编辑:

所以从昨天开始,我就尝试在视频流上工作。我无法在vitamio上解决它(不幸的是)。尽管尝试使用您提供的网址,并通过vlc应用将其流式传输。尽管我还没有尝试过,但是您可能可以使用LibVLC。我最终使用了webview并进行了一些设置,以使其看起来不像使用webview。

webView = findViewById(R.id.wvWebview);

webView.loadUrl("http://121.58.202.110:8080/jpeg?cam=4");
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);

sample stream