在 android 钛中录制视频和上传到服务器时面临的问题

issue facing in recording video and uploading to server in android titanium

我正在使用 Android 设备在使用钛平台的服务器上上传视频。我在检索数据时遇到以下问题。

No Activity found to handle Intent { act=android.media.action.VIDEO_CAPTURE dat=content://com.example.videoupload.tifileprovider/filesystem/storage/emulated/0/Android/data/com.example.videoupload/cache/_tmp/tia7257530851591479880.mp4 typ=video/* flg=0x3 }

以下是我使用的代码:-

Titanium.Media.showCamera( {
  success: function( event ) {
    // called when media returned from the camera
    if( ( event.mediaType === Ti.Media.MEDIA_TYPE_VIDEO ) && ( event.media !== null ) ) {

        //  AndroidSelectedImage(event.media.imageAsThumbnail(300));

        var image = event.media;
        var intent = Ti.Android.createIntent( {
            action: "android.media.action.VIDEO_CAPTURE",
            //action : Ti.Android.ACTION_PICK,
            //flags : Titanium.Android.FLAG_GRANT_READ_URI_PERMISSION | Titanium.Android.FLAG_GRANT_WRITE_URI_PERMISSION,
            //data : event.media.getFile().nativePath,
            type: 'video/*',
        } );

        var activity = require( 'main' ).activity;
        //winCertificate.getActivity()
        activity.startActivityForResult( intent, function( param ) {
            Ti.API.info( 'intent :- ' + JSON.stringify( intent ) );
            Ti.API.info( 'intent 1:- ' + JSON.stringify( param ) );

        } );
    } );
} );

在这种情况下帮助我。提前致谢

使用 HttpClient 将您的视频直接发送到服务器

success: function( event ) {
    if( ( event.mediaType === Ti.Media.MEDIA_TYPE_VIDEO ) && ( event.media !== null ) ) {
        var client = Ti.Network.createHTTPClient( {
            onload: function( e ) {
                alert( 'success' );
            },
            onerror: function( e ) {
                alert( 'error' );
            },
            timeout: 0
        } );
        client.open( "GET", URL );
        client.send( {
            video: media.video
        } );
    }
}

用钛activity这样开始

Ti.Android.currentActivity.startActivity(intent);