Skip to content

Doesn't work for Arabic locale #87

Closed

Description

@saeed74

if user has been selected persian or arabic language from settings of the device, the video cache will not work because of arabic/persian digits in pingUrl:

Logcat:

Open connection  to http://127.0.0.1:۴۲۵۸۹/ping
Error reading ping response
com.danikula.videocache.ProxyCacheException: Error opening connection for http://127.0.0.1:۴۲۵۸۹/ping with offset 0

i just solved the problem by adding a method in HttpProxyCacheServer.java:

Here is Codes:

String pingUrl = appendToProxyUrl(PING_REQUEST);
String CorrectpingUrl = convertToEnglishDigits(pingUrl);
HttpUrlSource source = new HttpUrlSource(CorrectpingUrl);

and here is the convertToEnglishDigits method code:

public static String convertToEnglishDigits(String value)
{
    String newValue = value.replace("١", "1").replace("٢", "2").replace("٣", "3").replace("٤", "4").replace("٥", "5")
            .replace("٦", "6").replace( "٧","7").replace("٨", "8").replace("٩", "9").replace("٠", "0")
            .replace("۱", "1").replace("۲", "2").replace("۳", "3").replace("۴", "4").replace("۵", "5")
            .replace("۶", "6").replace("۷", "7").replace("۸", "8").replace("۹", "9").replace("۰", "0");
    return newValue;
}

Activity

  1. saeed74 commented on Sep 5, 2016

    @saeed74
    Author

    Oh And Another Problem When Language is Persian/Arabic:
    When Useing this code:

    HttpProxyCacheServer proxy = App.getProxy(context);
    String proxyUrl = proxy.getProxyUrl(data);
    mPlayer.setDataSource(ProxyUrl);
    

    the proxyUrl will be like below:

    http://127.0.0.1:۵۷۹۷۱/https%3A%2F%2Fdl.dropboxusercontent.com%2Fs%2Fb0pbv3c1y6ssw16%2Fmardome_shahr.mp3

    that is obvious will not work and it respond with MediaPlayer Error (1, -1004).
    I used convertToEnglishDigits method again for handle this:

    HttpProxyCacheServer proxy = App.getProxy(context);
    String proxyUrl = proxy.getProxyUrl(data);
    String correctProxyUrl = App.convertToEnglishDigits(proxyUrl);
    mPlayer.setDataSource(correctProxyUrl);
    

    btw Thank You for Your Library<3

    EDIT 1:
    still getting some errors like MediaPlayer: error (100, 0) or MediaPlayer: error (-38, 0) ONLY if language is persian/arabic.

    I will wait for your solution. thanks again

    EDIT 2:
    setting app language in Application Class is another solution that I found:

    public class App extends Application {
    @Override
        public void onCreate() {
            super.onCreate();
    
            Configuration newConfig  = new Configuration();
            newConfig.locale = Locale.ENGLISH;
            super.onConfigurationChanged(newConfig);
            Locale.setDefault(newConfig.locale);
            getBaseContext().getResources().updateConfiguration(newConfig, getResources().getDisplayMetrics());
    
        }
    

    working good but i dont know why i feel bad about it!

  2. changed the title [-]VideoCache Not Working When Language of Phone is Arabic/Persian[/-] [+]Doesn't work for Arabic locale[/+] on Sep 5, 2016
  3. added a commit that references this issue on Sep 5, 2016
  4. danikula commented on Sep 5, 2016

    @danikula
    Owner

    @saeed74 fixed in 2.6.1. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions