小编Pir*_*aba的帖子

在AVPlayer顶部绘制按钮

我必须在视频顶部绘制标签或按钮relay next previous , leave comment.视频列表有它,一旦用户从表中选择一个项目,它需要播放,一旦播放器播放完成,那些按钮或标签应该出现在视频的顶部

这是我的代码:

    comPlayerControl = AVPlayerViewController()

            if let player = comPlayerControl {

                let videoURL: String = "http://cdnapi.kaltura.com/p/11/sp/11/playManifest/entryId/"+selectedSubmission.transcodeRefId+"/format/applehttp/protocol/http/a.m3u8"
                let playerItem = AVPlayerItem(URL: NSURL(string: videoURL)! )
                commmentPlayer = AVPlayer(playerItem: playerItem)
                player.player = commmentPlayer
                player.view.frame = videoCell.frame
                player.view.sizeToFit()

                player.showsPlaybackControls = true
                NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(CommentsTableViewController.playerDidFinishPlaying(_:)),
                    name: AVPlayerItemDidPlayToEndTimeNotification, object: playerItem)

                comPlayerControl.delegate = self
                videoCell.addSubview(player.view)
            }



     func playerDidFinishPlaying(note: NSNotification) {
    print("Video Finished")
    let DynamicView=UIView(frame: CGRectMake(100, 200, 100, 100))
    DynamicView.backgroundColor=UIColor.greenColor()
    DynamicView.layer.cornerRadius=25
    DynamicView.layer.borderWidth=2
    DynamicView.layer.zPosition = 1;
    comPlayerControl.view.addSubview(DynamicView)
}
Run Code Online (Sandbox Code Playgroud)

像这样的要求

要求图像

avfoundation ios avplayer swift avplayerviewcontroller

8
推荐指数
1
解决办法
1万
查看次数

Android Spinner错误:android.view.WindowManager $ BadTokenException:无法添加窗口

我想使用String []或ArrayList设置微调器值.

我在其他活动中做了微调器工作正常.在Tab acivityGroup内的这个活动中另一个Tab活动.

我的问题是将值设置为微调器.Spinner正确显示Thay意味着在加载活动时,工作正常但是当我单击On spinner时它会给出错误:

错误是:

    09-30 16:11:37.693: ERROR/AndroidRuntime(699): FATAL EXCEPTION: main
09-30 16:11:37.693: ERROR/AndroidRuntime(699): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@407f4de8 is not valid; is your activity running?
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.view.ViewRoot.setView(ViewRoot.java:527)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.app.Dialog.show(Dialog.java:241)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.widget.Spinner.performClick(Spinner.java:260)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.view.View$PerformClick.run(View.java:9080)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at android.os.Handler.handleCallback(Handler.java:587)
09-30 16:11:37.693: ERROR/AndroidRuntime(699):     at …
Run Code Online (Sandbox Code Playgroud)

android

6
推荐指数
1
解决办法
2万
查看次数

Android SQLite事务回滚工具?

我必须独立插入三个表..但如果第一个表成功插入,则只需要第二个表来插入数据.如果在插入第二个表时发生任何错误,则需要回滚第一个表的最后一个表,同样也是第三个表:

我当前喜欢这个:

   DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(RetailerOrderActivity.this);
dbAdapter.openDataBase();
   for (Map.Entry<String, MyProduct> entry : myProductMap.entrySet()) {
                    String key = entry.getKey();
                    MyProduct myProduct = entry.getValue();

                    ContentValues initialValue = new ContentValues();
                    initialValue.put("BusinessUnit",strBusinessUnit);
                    initialValue.put("ExecutiveCode",strExecutive);

                    if(salesType.equalsIgnoreCase("I")){
                        initialValue.put("InvoiceNo",transactionControl.getNextInvoiceNo());
                        initialValue.put("SalesCategory",transactionControl.getInvoicePrefix());

                    }else if(salesType.equalsIgnoreCase("O")){
                        initialValue.put("InvoiceNo",transactionControl.getNextOrderNo());
                        initialValue.put("SalesCategory",transactionControl.getOrderPrefix());
                    }
                    initialValue.put("ProductCode",key);
                    initialValue.put("LineNumber",i);
                    initialValue.put("Qty",myProduct.getQty());
                    initialValue.put("UnitPrice",myProduct.getPrice());
                    initialValue.put("DiscountValue",myProduct.getDisValue());
                    initialValue.put("DiscountQty",myProduct.getDisQty());


                    long nl = dbAdapter.insertRecordsInDB("WMInvoiceLine", null, initialValue); 

                   //update WMStockRecord table
                    if(nl != -1 ){

                        if((salesType.equalsIgnoreCase("I") && orderStockValidation.equals("1")) || (salesType.equalsIgnoreCase("O") && orderStockValidation.equals("1"))){
                            ContentValues stockValue = new ContentValues();
                            if(myProduct.getAvailableQuantity() < myProduct.getQty()){
                                stockValue.put("Stock",0.00);
                            }else{
                                double tmp = myProduct.getAvailableQuantity() - myProduct.getQty();
                                stockValue.put("Stock",tmp); …
Run Code Online (Sandbox Code Playgroud)

sqlite android

6
推荐指数
1
解决办法
6007
查看次数

TableLayout ScrollView垂直和水平

我们如何ScrollView纵向和横向设置?我尝试了下面的代码,但它没有用.

<ScrollView
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:background="@color/red"
 android:scrollbarFadeDuration="1000"
 android:scrollbarSize="12dip" >

   <HorizontalScrollView
     android:id="@+id/horizontalScrollView1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content" >

      <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:collapseColumns="2"
        android:stretchColumns="1" >
    </TableLayout>
</HorizontalScrollView>

<ScrollView >
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

这是我的所有代码:http://pastebin.com/ysRhLMyt

当前屏幕:

在此输入图像描述

我想总是显示滚动条.

android scrollbar

5
推荐指数
1
解决办法
2万
查看次数

Android Toast消息显示

我有产品清单.当用户单击该行时,Toastmsg将显示产品的名称.

我想Toast在每个产品行上显示.我想在用户点击列表行的地方显示Toast

看我的照片;

在此输入图像描述 目前显示列表中心:

我喜欢这样:

tablerow.setOnClickListener(new View.OnClickListener() {

    public void onClick(View view) {

        Toast prName = Toast.makeText(RetailerOrderActivity.this,
            " Name : " + productList.get(Integer.parseInt(view.getTag().toString())).getDescription(),
            Toast.LENGTH_SHORT);
        prName.setGravity(Gravity.AXIS_SPECIFIED, 0, 0);
        prName.show();
    }
});
Run Code Online (Sandbox Code Playgroud)

java android toast android-layout

5
推荐指数
1
解决办法
5360
查看次数

Android Softkeyboard将数值输入edittext非常慢

我有TableLayout,其中包含多个产品.每行包含代码,描述数量,价格,折扣价值,.....取决于用户输入数量,折扣价值,折扣数量和其他一些值也会计算.

当用户点击editText软键盘时,这个也可以,工作正常

我的问题是当用户按下数字键非常慢以在EditText中显示.

例如我从键盘按3,经过7或8秒后只显示在特定的editText中.如何缩短此时间线...

这是我的产品图片:

ProductImage

请有人建议为什么会这样?

像这样的代码:

     for (int i = initil; i <end; i++) {
        .............
        ............
        final EditText txtQty = new EditText(this);
            txtQty.setHeight(1);
            txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 42));
            txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
            txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
            txtQty.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            txtQty.setSelectAllOnFocus(true);
            txtQty.setTextSize(9);
            txtQty.setHint("0.0");
    //      txtQty.setOnEditorActionListener(new DoneOnEditorActionListener());
//          txtQty.setHighlightColor(R.color.green);
            tr.addView(txtQty); 

            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.showSoftInput(txtQty, InputMethodManager.SHOW_IMPLICIT);

            mgr.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_IMPLICIT_ONLY);
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(txtQty.getWindowToken(), 0);

            txtQty.setOnEditorActionListener( new OnEditorActionListener() {
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    Log.i("KeyBoard" ,"Inside the Edit Text");
                    .............................
        } });
Run Code Online (Sandbox Code Playgroud)

android soft-keyboard

5
推荐指数
1
解决办法
2284
查看次数

使用或不使用RegEx提取YouTube ID

请告诉我如何在不使用正则表达式的情况下获取youtube ID?

使用以下URL方法,无法正常工作

http://www.youtube.com/e/dQw4w9WgXcQ

http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ

public static String extractYTId(String youtubeUrl) {
    String video_id = "";

    try {
        if(youtubeUrl != null && youtubeUrl.trim().length() > 0 && youtubeUrl.startsWith("http")) {
            String expression = "^.*((youtu.be" + "\\/)" + "|(v\\/)|(\\/u\\/w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*"; // var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
            //String expression = "^.*(?:youtu.be\\/|v\\/|e\\/|u\\/\\w+\\/|embed\\/|v=)([^#\\&\\?]*).*";
            CharSequence input = youtubeUrl;
            Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
            Matcher matcher = pattern.matcher(input);
            if(matcher.matches()) {
                String groupIndex1 = matcher.group(7);
                if(groupIndex1 != null && groupIndex1.length() == 11)
                    video_id = groupIndex1;
            }
        }
    } catch(Exception e) { …
Run Code Online (Sandbox Code Playgroud)

java regex youtube

5
推荐指数
1
解决办法
2201
查看次数

查找Android GPRS状态

我有销售应用程序.这个应用程序由销售代表使用.所以我们无法确定任何WiFi或3G可用.所以我必须检查GPRS连接.&Sales rep需要进行复制.如果GPRS强度高于特定速率,则允许进行复制.

如何找到GPRS是启用?我想打电话给webservice.First它检查WIFI,3G,然后是GPRS.

对于WIFI,3G,我确实喜欢这个

 ConnectivityManager manager = (ConnectivityManager) getSystemService(DownlaodTableActivity.CONNECTIVITY_SERVICE);
    Boolean is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
    Boolean isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
    if(isWifi ){ ..... } else if(is3g){ ..... } else if(GPRS) {....}
Run Code Online (Sandbox Code Playgroud)

对于GPRS,我做了类似的事情:https://stackoverflow.com/questions/6898568/how-to-get-the-gsm-strength-outside-method

请有人告诉我如何进行GPRS连接.

(销售代表必须使用GPRS连接可用的电话.)

android gprs

3
推荐指数
1
解决办法
2716
查看次数

Android EditText OnClickListener问题

我有销售申请.当用户单击EditText时,弹出计算器想要显示.在我的情况下,当用户双击EditText onClickLister它时,它会显示弹出计算器.

这是myEditText

    final EditText txtQty = new EditText(this);
            txtQty.setHeight(1);
            if(productList.get(i).getQty() != 0.00){
                txtQty.setText(Double.toString(productList.get(i).getQty()));
            }
            txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,42));
            txtQty.setTextSize(9);
            txtQty.setId(i);
            txtQty.setHint("0");
            txtQty.setClickable(true);
            txtQty.setSelected(true);
            txtQty.setSelectAllOnFocus(true);
            txtQty.setInputType(InputType.TYPE_NULL);
            tr.addView(txtQty); 
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

   txtQty.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    String productCode= txtCode.getText().toString();
                    double price = getProductPrice(productCode).getPrice();
                    txtPrice.setText(""+price);

                    if(invPriceEdit.equals("3")){ 
                        if(editPrice.getText().toString().equals("") || editPrice.getText().toString().equals("0.00") || editPrice.getText().toString().equals("0") || editPrice.getText().toString().equals("0.0")){
                            txtPrice.setText(""+ price);
                            editPrice.setText("" +price);
                        }else{
                            String ePrice = editPrice.getText().toString();
                            editPrice.setText("" +ePrice);
                        }
                    }


                        keyAmount = new StringBuffer();
                        if(keyAmount.length() > 0){
                            keyAmount.delete(0, keyAmount.length());
                        }

                        int[] origin = new int[2]; …
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
2
解决办法
6897
查看次数

检测以纵向或横向方式全屏播放的视频

我参与了两天多.我无法得到任何解决方案.

我有要求是视频应该播放肖像内联,全屏,风景.我的问题是如何识别视频正在播放全屏风景或人像.我已经实现了viewWillTransitionToSize方法.但是AVPlayer有全屏箭头按钮.我如何识别用户点击该选项.

第二个要求,一旦视频完成,就可以在视频节目重放或下一个或上一个选项之上创建视图.

这是我的代码;

 if videoCellVal == nil {
            videoCellVal = videoCell

            comPlayerControl = AVPlayerViewController()

            if let player = comPlayerControl {

                let videoURL: String = "http://cdnapi.kaltura.com/p/11/sp/11/playManifest/entryId/"+selectedSubmission.transcodeRefId+"/format/applehttp/protocol/http/a.m3u8"
                let playerItem = AVPlayerItem(URL: NSURL(string: videoURL)! )
                commmentPlayer = AVPlayer(playerItem: playerItem)
                player.player = commmentPlayer
                player.view.frame = videoCell.frame
                player.view.sizeToFit()
                player.showsPlaybackControls = true
                NSNotificationCenter.defaultCenter().addObserver(self, selector: "playerDidFinishPlaying:",
                    name: AVPlayerItemDidPlayToEndTimeNotification, object: playerItem)


                videoCell.addSubview(player.view)
            }

        }

      func playerDidFinishPlaying(note: NSNotification) {
    print("Video Finished")
    let DynamicView=UIView(frame: CGRectMake(100, 200, 100, 100))
    DynamicView.backgroundColor=UIColor.greenColor()
    DynamicView.layer.cornerRadius=25
    DynamicView.layer.borderWidth=2
    DynamicView.bringSubviewToFront(self.view)
    self.view.addSubview(DynamicView)
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

iphone video ios swift

3
推荐指数
1
解决办法
4952
查看次数