Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24347] Android: Get image frames at times out of local video

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-03-03T15:30:16.000+0000
Affected Version/sRelease 6.0.0, Release 6.1.0
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsqe-6.1.0
Reporter Ricardo Ramirez
AssigneeGary Mathews
Created2017-01-25T19:30:51.000+0000
Updated2017-03-09T19:46:59.000+0000

Description

Issue Description

Customer want to get some thumbnails from a video in android using the function Titanium.Media.VideoPlayer.requestThumbnailImagesAtTimes, but it seems not being working with local videos. Using this function with a remote video, it works just fine, trying with a local video on android and call this function and it just doesn't work.

Steps to Reproduce

Create a new Alloy Project

Replace the index.js code for the next

var videoPlayer = null,
    videoUri = null;

//ThumbSelector is a slider with values from 0 to selected video length
$.thumbSelector.addEventListener("change", function(e) {
    if (videoPlayer && e.value > 0) {
        videoPlayer.requestThumbnailImagesAtTimes([e.value], Titanium.Media.VIDEO_TIME_OPTION_CLOSEST_SYNC, function(thumbCallback) {
            $.thumb.image = thumbCallback.image;
        });
    }
});

function durationavailable(e) {
    $.thumbSelector.max = Math.floor(e.duration / 1000);
    $.thumbSelector.show();
};

function openVideo() {
    var intent = Ti.Android.createIntent({
        action: Ti.Android.ACTION_PICK,
        type: "video/*"
    });
    intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
    $.index.getActivity().startActivityForResult(intent, function(e) {
        if (e.error) {
            Ti.UI.createAlertDialog({
                title: "Error",
                message: "Loading error..."
            }).show();
        } else {
            if (e.resultCode === Titanium.Android.RESULT_OK) {
                var videoUri = e.intent.data;

                var closePlayerBtn = Ti.UI.createButton({
                    title: "Close",
                    height: 40,
                    width: 100,
                    top: 15
                });
                // videoUri = source.nativePath;
                videoPlayer = Titanium.Media.createVideoPlayer({
                    url: videoUri,

                    scalingMode: Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
                    fullscreen: false,
                    autoplay: true
                });
                videoPlayer.addEventListener("durationavailable", durationavailable);

                videoPlayer.add(closePlayerBtn);

                closePlayerBtn.addEventListener("click", function() {
                    videoPlayer.hide();
                    videoPlayer.release();
                    videoPlayer = null;
                });
                $.vwPlayerWrapper.add(videoPlayer);
            } else {
                Ti.UI.createAlertDialog({
                    title: "Error",
                    message: "Loading error..."
                }).show();
            };
        };
    });
};

$.index.open();

replace the index.xml code to the next

<Alloy>
    <Window class="container">
        <ScrollView top="0" bottom="0" width="Ti.UI.FILL" layout="vertical">
            <View height="Ti.UI.SIZE" top="0">
                <Button onClick="openVideo">Open Video</Button>
            </View>
            <View id="vwPlayerWrapper" height="300" width="Ti.UI.FILL" backgroundColor="#000">
                <!-- HERE GOES THE VIDEO PLAYER -->
            </View>
            <View height="100" top="10" layout="horizontal" >
                <Slider id="thumbSelector" width="70%" min="0" max="100" height="Ti.UI.SIZE" visible="false" top="5"></Slider>
                <ImageView id="thumb" height="40" width="40" borderColor="#000" top="5"></ImageView>
            </View>
            <ImageView id="test" backgroundColor="#000" width="200" height="Ti.UI.SIZE"></ImageView>
        </ScrollView>
    </Window>
</Alloy>

Run

Load local video

Try to get the image

Facts: - This is not working with any local video on Android - This work fine on iOS. - By 'local video' we mean videos picked from the video gallery of the device

Attachments

FileDateSize
test.png2017-02-10T15:59:16.000+0000405771

Comments

  1. Gary Mathews 2017-02-10

    master: https://github.com/appcelerator/titanium_mobile/pull/8830
  2. Ricardo Ramirez 2017-03-02

    Guys when the review is finished?
  3. Josh Longton 2017-03-09

    {noformat} Mac OS Version : 10.12.3 Appc CLI : 6.1.0 Appc NPM : 4.2.9-1 Node : v4.6.0 Device: Nexus 5x(6.0.1) Pixel XL(7.1.1) Emulator: (6.0), (4.4.2) {noformat} Using above env passed FR. After merge, the changes are present in SDK 6.1.0.v20170307133328. *Closing*

JSON Source